Update array (Go).

This commit is contained in:
Yudong Jin
2023-01-06 03:28:27 +08:00
parent f34dde9c65
commit 30b4ab6ba7
3 changed files with 8 additions and 7 deletions

View File

@@ -44,7 +44,10 @@ comments: true
```go title="array.go"
/* 初始化数组 */
var arr []int
var arr [5]int
// 在 Go 中,指定长度时([5]int为数组不指定长度时[]int为切片
// 由于 Go 的数组被设计为在编译期确定长度,因此只能使用常量来指定长度
// 为了方便实现扩容 extend() 方法以下将切片Slice看作数组Array
nums := []int{1, 3, 2, 5, 4}
```