Arrays
An array has a fixed length that is part of its type.
Example
package main
import "fmt"
func main() {
var a [3]int
a[0] = 7
b := [3]string{"x", "y", "z"}
c := [...]int{1, 2, 3, 4}
fmt.Println(a, b, len(c))
}Result
[7 0 0] [x y z] 4
Exercise
Array length.
len()
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.