On Mon, Jan 16, 2012 at 12:09 PM, David Bruant <[email protected]> wrote:
> Thinking more about the current semantics, I thought that what is
> currently done could be achieved a bit differently:
> -----
> var v = wm.get(o, def);
> // almost equivalent to:
> var v = wm.get(o) || def;
> -----

This is a very common semantic in dictionaries, and it's extremely
useful.  I recommend adding it, either to get() as you describe, or in
a second function.  Python implements it both ways - the get()
function can take a second "default" value that is returned if the key
is not in the dict, and it provides a setdefault() function that sets
the key if and only if it's not already set, and then returns the
key's value.

~TJ
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to