A different semantics for WeakMap#get default value

Kris Kowal kris.kowal at cixar.com
Mon Jan 16 16:53:01 PST 2012

For what it’s worth, Python dictionaries have .get(key, default) and
.setdefault(key, default).  The former is non-mutating.  Its behavior
is also different depending on arguments length.  If the default is
not passed, it will throw an exception.  If a default is passed, even
if that default is None, it will not throw an exception.  I’ve found
both forms useful.

Kris Kowal

More information about the es-discuss mailing list