Arrays


An array can hold a series of values. Both the length and the type of the values of an array is fixed at the time we create it. Unlike in some other languages, you cannot mix different types of values in an array. The content can be changed. We can access the individual elements of an array with a post-fix square-bracket indexing.

examples/array/array.go
package main

import (
    "fmt"
)

func main() {
    var res = [3]int{7, 5, 9}

    fmt.Println(res)
    fmt.Println(res[1])
    fmt.Println(len(res))

    fmt.Printf("%T\n", res)
}

[7 5 9]
5
3
[3]int