Map#get needs a default value param?

David Bruant bruant.d at gmail.com
Tue Jun 12 07:36:01 PDT 2012


Le 12/06/2012 16:19, Hemanth H.M a écrit :
> Would it be useful to have something like sum[value] = sum.get(value, 
> 0) + 1
You can always do

     sum[value] = (sum.get(value) || 0) + 1;

I think it's simple enough to justify not having an additional (and 
potentially confusing) argument, but I'm open to debate.

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120612/5584a2d1/attachment.html>


More information about the es-discuss mailing list