Skip to content

Commit 098aa41

Browse files
authored
fix: code mismatch with description (#72)
Signed-off-by: simonwei97 <[email protected]>
1 parent b24e608 commit 098aa41

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

content/slice/1-数组和切片有什么异同.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ s2 = append(s2, 100)
8383
再次向 `s2` 追加元素200:
8484

8585
```golang
86-
s2 = append(s2, 100)
86+
s2 = append(s2, 200)
8787
```
8888

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

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

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

0 commit comments

Comments
 (0)