``` func b() { x := []int{} x = append(x, 0) x = append(x, 1) x = append(x, 2) y := append(x, 3) z := append(x, 6) fmt.Println(y) fmt.Println(z) } ``` 调用函数b 输出结果 ``` [0 1 2 6] [0 1 2 6] ``` 为什么 y和z输出是一样的? 2、 ``` func b() { x := []int{} x = append(x, 0) x = append(x, 1) x = append(x, 2) x = append(x, 3) y := append(x, 6) z := append(x, 7) fmt.Println(y) fmt.Println(z) } ``` x多append一个数,y和z的输出又不一样了, 为什么? golang版本1.13
有疑问加站长微信联系(非本文作者)
