Files
learning-go-jon-bodner/chapter-3-composite-types/01_arrays.go
2022-12-03 18:45:01 +00:00

21 lines
389 B
Go

// array literals are their own types
// [3]int is a different type to [4]int
package main
import "fmt"
func main() {
var x [3]int
x = [3]int{1, 2, 3}
fmt.Println(x)
// index 0=1, index 5=4, index 6=6, index 10=100, index 11=15, the rest 0
var y = [12]int{1, 5: 4, 6, 10: 100, 15}
fmt.Println(y)
// can leave the size off if initialising an array
var z = [...]int{1, 2, 3}
}