On Tue, Nov 10, 2020 at 10:03 PM 'Dan Kortschak' via golang-nuts <
golang-nuts@googlegroups.com> wrote:

> On Tue, 2020-11-10 at 20:28 -0800, 'Kilos' via golang-nuts wrote:
> > You cannot safely mutate a Go map while iterating over it with the
> > `range` operator.
>
> This is not true, depending on your definition of "safely". See
> https://golang.org/ref/spec#For_statements "For statements with range
> clause"
>


> So long as you take into account these caveats, mutating a map during a
> range will not corrupt the map or other data structure, and will cause
> your application to crash.
>

Jeebus. H. Christ! Yes, you can "safely" mutate a map while iterating over
it. In as much as doing so will not result in a panic; although, I'm not
convinced that is true. The point of the O.P. is that they expect the map
mutation to always be visible.

-- 
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank

-- 
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/CABx2%3DD8%2BnZboqttOCburtY6ahvRFQg82U1NkMxjuYXfBezbmgg%40mail.gmail.com.

Reply via email to