Arrays
Basic arrays
Section titled “Basic arrays”Arrays are fixed-size and zero-indexed:
var values: [4]Int = { 4, 8, 15, 16 };Declaring before filling
Section titled “Declaring before filling”var simple: [5]Int;Indexing
Section titled “Indexing”fun main() Int { var values: [3]Int = { 10, 20, 30 }; return values[1];}Nested arrays
Section titled “Nested arrays”var grid: [2][2]Int = { { 1, 2 }, { 3, 4 }};Example
Section titled “Example”fun sum(values: [4]Int) Int { return values[0] + values[1] + values[2] + values[3];}