Thanks!

On Tue, Jan 10, 2023, 10:31 AM wagner riffel <w...@104d.net> wrote:

> On 1/10/23 11:42, Daniel Jankins wrote:
> > Hi,
> >
> > Why can you update a value in a map struct?
> >
>
> Sort answer, because m["foo"] is not addressable, but you can have the
> desired behavior using a temp variable:
>
> func f() {
>         m := make(map[string]struct{ i int })
>         x := m["foo"]
>         x.i = 42
>         m["foo"] = x
> }
>
> BR.
> -- w
>
>

-- 
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/CACHdq70GYSHQTVVAe5FwWiURxwyBrqdQDdw9HPK8BT36z-R9UA%40mail.gmail.com.

Reply via email to