Go 数组的初始化
// ArrayFunc02 ... 四种初始化数组方式 func ArrayFunc02() { var array01 [3]int = [3]int{11, 22, 33} fmt.Println("array01=", array01) var array02 = [3]int{11, 22, 33} fmt.Println("array02=", array02) var array03 = [...]int{11, 22, 33} fmt.Println("array03=", array03) //类型推导,指定下标赋值 var array04 = [...]int{3: 11, 2: 22, 0: 33} fmt.Println("array04=", array04) }
运行结果