Array literals are constructed using the following syntax:
where exp is an arbitrary expression.
[1,2,3] constructs an array of three signed 32-bit
['a','b','c'] constructs an array of three
unsigned 8-bit integers (characters). For convenience, a trailing
comma is accepted but not required.
The type of the array literal is inferred from the type of its elements. Accordingly, all the elements in an array literal must be of the same type. Examples of invalid array literals, that will raise a compilation-time error if evaluated, are:
[1,2u,3] [1,0xffff_ffff,3] ['a',"b",'c']
Array literals must contain at least one element. Accordingly,
 is not a valid array literal.
This is how a
3x3 matrix could be constructed using an array of
It is possible to refer to specific elements when constructing array
literals. For example,
[1,2,3,. = 4] denotes the same
This allows creating arrays without having to specify all its
elements; every unspecified element takes the value of the first
specified element to its right. For example,
[. = 2]
denotes the same array as
Note that an array element can be referenced more than once. When
that happens, the final value of the element is the last specified.
[1,2,3,.=10] denotes the array