<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Feb 10, 2014 at 1:54 PM, Sina Samavati <span dir="ltr"><<a href="mailto:sina.samv@gmail.com" target="_blank">sina.samv@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div id=":og" style="overflow:hidden">From another perspective: add or update it, I don't want you to shout at me<br>
"Hey, there's no such key", because it will or will not be used. That's it.</div></blockquote></div><br>The reason := is in there is to catch errors. If you have a map</div><div class="gmail_extra"><br>
</div><div class="gmail_extra">M = #{ foo => 3 }</div><div class="gmail_extra"><br></div><div class="gmail_extra">and then accidentally write</div><div class="gmail_extra"><br></div><div class="gmail_extra">M#{ fou => 4 }</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">The resulting map will be</div><div class="gmail_extra"><br></div><div class="gmail_extra">#{ foo := 3, fou := 4 }</div><div class="gmail_extra"><br></div><div class="gmail_extra">
which is probably not what you want. The := operator makes such errors impossible.</div><div class="gmail_extra"><br></div><div class="gmail_extra">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.</div>
<div class="gmail_extra"><br><br clear="all"><div><br></div>-- <br>J.
</div></div>