I don’t think that is correct. You would have the same problem if you allocated 
m after the m2 assignment. 

> On Aug 9, 2026, at 11:56 AM, Jan Mercl <[email protected]> wrote:
> 
> On Sun, Aug 9, 2026 at 6:12 PM Tom Limoncelli <[email protected]> wrote:
>> 
>> Why don't maps allocate on the first attempt to store something in them?
>> 
>> We all know that maps need to be initialized:
>> 
>> var m map[string]string
>> m["foo"] = bar    // panics on STORE
>> 
>> Why can't it allocate ON FIRST STORE instead of panicking?
> 
> Because https://go.dev/play/p/UbN46-c9iyi
> 
> --
> 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 [email protected].
> To view this discussion visit 
> https://groups.google.com/d/msgid/golang-nuts/CAA40n-XS%3DUMmc9immQ%2Byguj4vQaa8xiLRVFuXrEheBR1f-aBVg%40mail.gmail.com.

-- 
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 [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/golang-nuts/BF08BE8A-DFD0-42F0-BC54-04DA8F18F4C3%40me.com.

Reply via email to