On Tue, Sep 24, 2019 at 10:11 PM Marcin Romaszewicz <
mar...@gmail.com> wrote:
>
> Could we have an operation like append() for slices?
>
> How about:
>
> m := insert(m, "key", "value").
A slice is a value but a map is implemented as a pointer. IOW, the
line of code quoted above updates only the locally visible copy of m.
All other copies of m are left at the old, possibly nil, value, but
that's not how maps in Go work. Once the map is initialized, all the
shared copies can access the same values/operations on it.