Array Indexing
// Declare an array of integers.
let numbers = [42, 23]
// Get the first number of the array.
//
numbers[0] // is `42`
// Get the second number of the array.
//
numbers[1] // is `23`
// Run-time error: Index 2 is out of bounds, the program aborts.
//
numbers[2]// Declare an array of arrays of integers, i.e. the type is `[[Int]]`.
let arrays = [[1, 2], [3, 4]]
// Get the first number of the second array.
//
arrays[1][0] // is `3`Last updated