set.add and set.delete return values

Andrea Giammarchi andrea.giammarchi at
Mon Feb 13 23:58:29 PST 2012

there is a typo in the Set delete definition, return
private(this).delete(key) should be return private(this).map.delete(key);

AFAIK add does behave indeed like that and it's in my shim indeed, add
returns true if added, false otherwise.

I would change that code into

add(key) { const map = private(this).map; return !(map.has(key) &&
map.set(key, true)); }


On Tue, Feb 14, 2012 at 6:28 AM, Peter Michaux <petermichaux at>wrote:

> The return value set.delete tells the caller if the set was modified
> or not. It would be useful if the return value of set.add did the
> same. For example, this way a model in MVC could efficiently know if
> and notify observers that a real change to the set actually happened.
> Peter
> _______________________________________________
> es-discuss mailing list
> es-discuss at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list