On Tue, Sep 24, 2019 at 10:11 PM Marcin Romaszewicz <marc...@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. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAA40n-X06rRJh9%3Dehkv7OszkNx2Lg2UyLzFqHesS4HF5d%3DU7fA%40mail.gmail.com.