docs(array.md): Added go array initialization code example
This commit is contained in:
parent
18c43566b4
commit
e248a5a643
@ -43,7 +43,13 @@ comments: true
|
||||
=== "Go"
|
||||
|
||||
```go title="array.go"
|
||||
|
||||
/* 初始化数组 */
|
||||
// 方法一
|
||||
nums1 := [5]int{1, 2, 3, 4, 5}
|
||||
// 方法二
|
||||
var nums2 [5]int
|
||||
// 在 Go 中数组必须指定长度,如果长度不确定,可以使用 ... 代替数组长度
|
||||
nums3 := [...]int{1, 2, 3, 4, 5}
|
||||
```
|
||||
|
||||
=== "JavaScript"
|
||||
|
Loading…
Reference in New Issue
Block a user