set.add and set.delete return values
# Andrea Giammarchi (13 years ago)
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)); }
br
# Andrea Giammarchi (13 years ago)
typo in my line too
add(key) { const map = private(this).map; return !map.has(key) && !map.set(key, true); }
...
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.
harmony:simple_maps_and_sets
Peter