List expressions

Syntax
ListExpression :
   [ ListElements? ]

ListElements :
   Expression (, Expression)* ,?

A list expression constructs array values.

The syntax for list expressions is a parenthesized, comma separated list of expressions, called the list initializer operands. The number of list initializer operands must be equal to the static size of the array type. The types of all list initializer operands must conform to the type of the array.

Examples of tuple expressions and their types:

ExpressionType
[1, self.get_number()]u256[2]
[true, false, false]bool[3]

An array item can be accessed via an index expression.

Example:

contract Foo:

    fn get_val3() -> u256:
        return 3

    pub fn baz():
        let val1: u256 = 2
        # A list expression
        let foo: u256[3] = [1, val1, get_val3()]