Arrays
Beginner · Collections & Loops
An array has a fixed length that is part of its type ([3]int ≠ [4]int).
Arrays are values: assigning or passing one copies all elements. Indexing is
zero-based. In practice slices are used far more often than arrays.
Resources
Section titled “Resources”Exercises
Section titled “Exercises”arrays1 compile
Section titled “arrays1 compile”Arrays are zero-indexed — fix the out-of-range access.
Show hint
Arrays use zero-based indexing.arrays2 compile
Section titled “arrays2 compile”An array can’t mix types; every element shares one type.
Show hint
Unlike languages like Python or Ruby, Go does not allow arrays with mixed data types.