3 ms·
I think slices are actually passed by value. From "Effective Go": "We must return the slice afterwards because, although Append can modify the elements of sli
by nulltype 12y ago
I think slices are actually passed by value.
From "Effective Go":
"We must return the slice afterwards because, although Append can modify the elements of slice, the slice itself (the run-time data structure holding the pointer, length, and capacity) is passed by value."
- jamra 12y agoYou are absolutely correct. To borrow form another's comment, https://play.golang.org/p/VOUJI88PNj https://play.golang.org/p/VOUJI88PNj The slice, however, is a small structure to pass to a function in that you are not performing a copy of each individual element in the slice.