import ballerina/io;

public function main() {
    int[] v = [1, 2, 3];

    // `v[i]` does indexed access.
    int n = v[0];

    io:println(n);

    // `v[i]` is an `lvalue`.
    v[3] = 4;

    // `len` will be 3.
    int len = v.length();

}

Arrays

T[] is an array of T. Arrays are mutable. == and != on arrays is deep: two arrays are equal if they have the same members in the same order. Ordering is lexicographical based on the ordering of the members. Langlib arr.length() function gets the length; arr.setLength(n) sets the length.

import ballerina/io;
public function main() {
    int[] v = [1, 2, 3];
    int n = v[0];

v[i] does indexed access.

    io:println(n);
    v[3] = 4;

v[i] is an lvalue.

    int len = v.length();

len will be 3.

}
bal run arrays.bal
1