From 20eb80226a57b7c3f2dc86ae6fd1a338665139b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?mafan=EF=BC=88=E9=BA=BB=E5=87=A1=EF=BC=89?= Date: Mon, 15 Aug 2022 17:45:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E6=94=B9=20helloword=20=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2.\345\210\207\347\211\207/slice.md" | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git "a/data/2.Go\350\257\255\350\250\200\344\270\255\351\230\266/1.\344\271\235\351\230\264\347\234\237\347\273\217/2.\345\210\207\347\211\207/slice.md" "b/data/2.Go\350\257\255\350\250\200\344\270\255\351\230\266/1.\344\271\235\351\230\264\347\234\237\347\273\217/2.\345\210\207\347\211\207/slice.md" index be733b6..df75dfc 100644 --- "a/data/2.Go\350\257\255\350\250\200\344\270\255\351\230\266/1.\344\271\235\351\230\264\347\234\237\347\273\217/2.\345\210\207\347\211\207/slice.md" +++ "b/data/2.Go\350\257\255\350\250\200\344\270\255\351\230\266/1.\344\271\235\351\230\264\347\234\237\347\273\217/2.\345\210\207\347\211\207/slice.md" @@ -3,25 +3,26 @@ ```Go func main() { - s := []int{1, 2, 3} // len=3, cap=3 + s := []int{1, 2, 3} a := s s[0] = 888 s = append(s, 4) - fmt.Println(a, len(a), cap(a)) // 输出:[888 2 3] 3 3 + fmt.Println(a, len(a), cap(a)) fmt.Println(s, len(s), cap(s)) // 输出:[888 2 3 4] 4 6 } ``` ## 答案 -`[1 2 3] 3 3` 和 `[1 2 3 4] 4 6` +`[888 2 3] 3 3` 和 `[888 2 3 4] 4 6` ## 选项 ### A -`[888 2 3] 3 3` 和 `[888 2 3 4] 4 6` + +`[1 2 3] 3 3` 和 `[1 2 3 4] 4 6` ### B -- GitLab