|
|
|
|
|
by tshadwell
4048 days ago
|
|
Your understanding is incorrect, too. append() only returns a new slice when "the capacity of s is not large enough to fit the additional values", in which case "append allocates a new, sufficiently large underlying array that fits both the existing slice elements and the additional values. Otherwise, append re-uses the underlying array." [-] http://golang.org/ref/spec#Appending_and_copying_slices |
|
The slice returned only points to a new array when the capacity is not large enough to fit additional values.