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 <keith.rand...@gmail.com> wrote:

> 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
>> 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
>>> addressable or map index expressions; they denote the iteration
>>> variables."
>>>
>>>
>>> Here is the thing I am having trouble imagining... if the iterator keeps
>>> a snapshot of the map at the time the iterator was created, would the map
>>> index expression obtain the actual, up-to-date value for the given key?
>>> Maybe even determine if it was deleted?
>>>
>>> I.E...
>>>
>>> for k, m[k] := range m {...}
>>>
>>> Apparently is valid Go syntax, however what are the semantics behind
>>> this? If another Goroutine calls delete(...) and removes that element from
>>> the map, would this pretty much restore that value back into the map (from
>>> what is held in the snapshot)? How would you go about retrieving that value
>>> again? Do you need to re-enter the map to obtain the value again through
>>> that key, 'k'? What are the practical applications for this?
>>>
>>> --
> 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.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to