Skip to content

Commit 7fb7128

Browse files
RickyWang1020Tinywan
authored andcommitted
Update golang_tutorial_11.md
1 parent c9fc5db commit 7fb7128

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

docs/golang_tutorial_11.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
## 声明
1414

15-
数组的类型为` [n]T`,其中 `n` 表示数组中元素的个数,`T` 表示数组中元素的类型。元素的个数 `n`也是数组类型的一部分(我们将在稍后详细讨论)。
15+
数组的类型为 `[n]T`,其中 `n` 表示数组中元素的个数,`T` 表示数组中元素的类型。元素的个数 `n` 也是数组类型的一部分(我们将在稍后详细讨论)。
1616

1717
有很多声明数组的方式,让我们一个一个地介绍。
1818

@@ -29,7 +29,7 @@ func main() {
2929
}
3030
```
3131

32-
`var a [3]int `声明了一个长度为 3 的整型数组。数组中的所有元素都被自动赋值为元素类型的 0 值。比如这里 a 是一个整型数组,因此 a 中的所有元素都被赋值为 0(即整型的 0 值)。运行上面的程序,输出为:`[0 0 0]`
32+
`var a [3]int` 声明了一个长度为 3 的整型数组。数组中的所有元素都被自动赋值为元素类型的 0 值。比如这里 a 是一个整型数组,因此 a 中的所有元素都被赋值为 0(即整型的 0 值)。运行上面的程序,输出为:`[0 0 0]`
3333

3434
数组的索引从 0 开始到 `length - 1` 结束。下面让我们给上面的数组赋一些值。
3535

@@ -49,7 +49,7 @@ func main() {
4949
}
5050
```
5151

52-
`a[0]`表示数组中的第一个元素。程序的输出为:`[12 78 50]`
52+
`a[0]` 表示数组中的第一个元素。程序的输出为:`[12 78 50]`
5353

5454
(译者注:可以用下标运算符(`[]`)来访问数组中的元素,下标从 0 开始,例如 `a[0]` 表示数组 a 的第一个元素,`a[1]` 表示数组 a 的第二个元素,以此类推。)
5555

0 commit comments

Comments
 (0)