|
|
|
|
|
by erik_seaberg
1469 days ago
|
|
s2 := append(s1, x)
s3 := append(s1, y)
shouldn’t be allowed, because what it’s likely to do is not what anyone meant. In a pass-by-value language, passing a slice or map by value should copy it, append should be a method that returns void, and passing a pointer should be the way to share state and avoid copies. |
|
I'd expect to have two different slices, s2 and s3, to contain all the same elements aside from the last.
[a, b, c, x] and [a, b, c, y] and s1 remains [a, b, c]