I just wanted to leave a note saying that PR #23601 will be changing the index operator to operate by value, as specified in RFC 439. Note that this is a breaking change in that maps now have to be indexed using a reference (
map[key]); some map lookups using constant string keys, however, are simpler, as one can do
map["foo"] and not
map[*"foo"]. As described in the RFC, the motivation for this change is that it unifies the behavior of the operators (comparison operators are by ref, all others by value) and helps prepare for a future option to insert into maps by doing
map[key] = value (support for this is part of the RFC but not yet implemented).