Re: [go-nuts] Re: Using "map index expressions" as the value for a range loop

2016-07-09 Thread Matt Harden
OK, after initializing k to an actual value, I see what's happening: k = "" prior to the loop m = {"foo": 314, "bar": 42} prior to the loop loop, round 1 k gets set to "foo" m[""] gets set to 314 -- AND by chance, the map iterator is going to visit this new map entry later (round 3). m["foo"] ge

Re: [go-nuts] Re: Using "map index expressions" as the value for a range loop

2016-07-09 Thread Matt Harden
OK but based on Jesse's explanation, I expect the map to contain keys "bar" and "". But in fact, in the playground at least, we get "foo" and "bar", with the values reversed: foo bar map[foo:314 bar:42] I can't think of a valid explanation for that behavior. On Thu, Jul 7, 2016 at 4:44 PM wr

[go-nuts] Re: Using "map index expressions" as the value for a range loop

2016-07-07 Thread keith . randall
I don't think there are any. Because you can do it doesn't mean you should. It's incredibly confusing for readers (hence the confusion in this thread). On Thursday, July 7, 2016 at 8:52:06 AM UTC-7, Kyle Stanly wrote: > > So, what would be the appropriate use-cases for this; I.E, using a map

[go-nuts] Re: Using "map index expressions" as the value for a range loop

2016-07-07 Thread Kyle Stanly
So, what would be the appropriate use-cases for this; I.E, using a map index expression as the value? On Thursday, July 7, 2016 at 10:05:42 AM UTC-4, Kyle Stanly wrote: > > I noticed that the specification states: > > "As with an assignment, if present the operands on the left must be > addressa