Skip to content

Commit 9ee7b2a

Browse files
committed
🎨 go-06
1 parent dfa5bfa commit 9ee7b2a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

go-06/array_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,13 @@ func TestSliceGrowing(t *testing.T) {
4141
s=append(s,i)
4242
t.Log(len(s),cap(s))
4343
}
44+
}
45+
46+
//共享数组修改会影响使用的数据,容易出错
47+
func TestSliceShare(t *testing.T) {
48+
s:=[]string{"1","2","3","4","5"}
49+
Q:=s[3:5]
50+
t.Log(Q,len(Q),cap(Q))
51+
su:=s[1:3]
52+
t.Log(su,len(su),cap(su))
4453
}

0 commit comments

Comments
 (0)