|
|
|
|
|
by nicksardo
4048 days ago
|
|
The use of `append` is absolutely clear. It always returns a new slice; the compiler forces you to take the value returned. What scares you is the possibility that the underlying array may be copied to a newer, larger array giving enough space for the appended items. If there exists enough space, why bother with a new allocation? I want `append` to handle this for me. If you want different behavior, you can easily setup your own design with `copy` Regarding this blog post, if you have multiple slices to the same array and are arbitrarily appending to any of those slices, then your design is wrong to begin with. This isn't an edge-case but a lack of slice understanding. |
|