docs(array): Added golang array init code example

This commit is contained in:
龚国玮 2022-12-26 12:02:35 +08:00
parent e248a5a643
commit 80dfab528e

View File

@ -44,12 +44,8 @@ comments: true
```go title="array.go" ```go title="array.go"
/* 初始化数组 */ /* 初始化数组 */
// 方法一 var arr [5]int // {0, 0, 0, 0, 0}
nums1 := [5]int{1, 2, 3, 4, 5} nums := [5]int{1, 3, 2, 5, 4}
// 方法二
var nums2 [5]int
// 在 Go 中数组必须指定长度,如果长度不确定,可以使用 ... 代替数组长度
nums3 := [...]int{1, 2, 3, 4, 5}
``` ```
=== "JavaScript" === "JavaScript"