Skip to content

Latest commit

 

History

History
24 lines (17 loc) · 549 Bytes

数组.rst

File metadata and controls

24 lines (17 loc) · 549 Bytes

数组

数组是一个由固定长度的特定类型元素组成的序列,一个数组可以由零个或多个元素组成。因为数组的长度是固定的,所以在Go语言中很少直接使用数组。

声明方式

var 数组变量名 [元素数量]Type

遍历数组

var team [3]string
team[0] = "hammer"
team[1] = "soldier"
team[2] = "mum"
for k, v := range team {
    fmt.Println(k, v)
}