Skip to content

Commit

Permalink
fix: code mismatch with description (#72)
Browse files Browse the repository at this point in the history
Signed-off-by: simonwei97 <simonwei977@gmail.com>
  • Loading branch information
simonwei97 authored Apr 16, 2024
1 parent b24e608 commit 098aa41
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions content/slice/1-数组和切片有什么异同.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ s2 = append(s2, 100)
再次向 `s2` 追加元素200

```golang
s2 = append(s2, 100)
s2 = append(s2, 200)
```

这时`s2` 的容量不够用该扩容了于是`s2` 另起炉灶将原来的元素复制新的位置扩大自己的容量并且为了应对未来可能的 `append` 带来的再一次扩容`s2` 会在此次扩容的时候多留一些 `buffer`将新的容量将扩大为原始容量的2倍也就是10了
Expand All @@ -100,4 +100,4 @@ s1[2] = 20

![s1[2]=20](../assets/4.png)

再提一点打印 `s1` 的时候只会打印出 `s1` 长度以内的元素所以只会打印出3个元素虽然它的底层数组不止3个元素
再提一点打印 `s1` 的时候只会打印出 `s1` 长度以内的元素所以只会打印出3个元素虽然它的底层数组不止3个元素

0 comments on commit 098aa41

Please sign in to comment.