2022-12-03

This commit is contained in:
2022-12-03 18:45:01 +00:00
parent 2b06d563b4
commit 3da7b7dbc7

View File

@@ -1 +1,20 @@
// array literals are their own types
// [3]int is a different type to [4]int
package main 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}
}