Declaring arrays
Declaring one-dimensional arrays
A one dimensional fixed array is created either via an array literal or via appending []
to the type of the variable with the size or *
(for an infinite array) between the brackets. If no variable type is given, the type array is infered on first use and the variable will be an infinite array
Example
Declaring arrays with mixed types
An array of *any
can contain data of multiple types. This means that the array can be used as a tuple.
Declaring multi-dimensional arrays
The syntax of creating multi-dimensional arrays is similar to that of creating one-dimensional arrays. But instead of a single size, you put the size of each dimension between the brackets seperated by a ,
.
Example
Arrays of nullable types
Making an array nullable is done in the same way as making a variable nullable: you put a ?
in front of the datatype or let the interpreter infer the array type.
Example
Last updated