[erlang-questions] Maps single value access not implemented

Jesper Louis Andersen <>
Mon Feb 10 16:49:57 CET 2014

On Mon, Feb 10, 2014 at 1:54 PM, Sina Samavati <> wrote:

> From another perspective: add or update it, I don't want you to shout at me
> "Hey, there's no such key", because it will or will not be used. That's it.

The reason := is in there is to catch errors. If you have a map

M = #{ foo => 3 }

and then accidentally write

M#{ fou => 4 }

The resulting map will be

#{ foo := 3, fou := 4 }

which is probably not what you want. The := operator makes such errors

The other, more subtle, benefit is that if a map is updated with := only,
then the keys can be shared among the different maps. This yields good
space behavior in the long run.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140210/3e862ca4/attachment.html>

More information about the erlang-questions mailing list