标签:des style blog color io ar sp div on
The type [n]T
is an array of n
values of type T
.
The expression
var a [10]int
declares a variable a
as an array of ten integers.
An array‘s length is part of its type, so arrays cannot be resized. This seems limiting, but don‘t worry; Go provides a convenient way of working with arrays.
package main import "fmt" func main() { var a [2]string a[0] = "Hello" a[1] = "World" fmt.Println(a[0], a[1]) fmt.Println(a) }
标签:des style blog color io ar sp div on
原文地址:http://www.cnblogs.com/ghgyj/p/4053312.html