Arrays

Contents

Arrays#

Arrays have a fixed size baked into the type. [3]int and [4]int are different types. Rarely used directly; the operator reaches for slices.

Zero-valued array of three ints.

var a [3]int                 // [0 0 0]

Array literal with explicit length.

a := [3]int{1, 2, 3}

Inferred length with [...].

a := [...]int{1, 2, 3}       // size inferred (3)

References#

  • Slices for the variable-length view-over-array form.