Set add, clear, and delete methods: multiple arguments and return values

# Peter Michaux (12 years ago)

Posted in another thread but I was asked to create a dedicated thread...


15.16.4.2

I think it would be useful if Set.prototype.add could take multiple values

Instead of

set.prototype.add(a);
set.prototype.add(b);
set.prototype.add(c);

allow the following

set.prototype.add(a, b, c);

It would be useful to know if the set was modified as a result of the add call. Step 8.a.i return false. Step 9 return true. This would allow a model layer in an MVC application to know if a "change" event needs to be fired or not.


15.16.4.3

It would be useful to know if the set was modified as a result of the clear call. For a previously empty set, clear would return false. Otherwise true.


15.16.4.4

Delete is good because it returns true or false indicating if the set was modified or not.

The add, clear, and delete method's have very inconsistent return values. Returning true or false for all depending if the set was modified or not would be great.

Could delete take multiple arguments, all of which will be deleted from the set?


Peter