Skip to content

Set.add should return a bool to indicate if the value already existed #3546

Closed
@peter-ahe-google

Description

@peter-ahe-google

Similarly to Set.remove, Set.add should return a bool so one can avoid doing:

if (mySet.contains(o)) { throw 'not unique'; }
mySet.add(o);

And instead do:

if (!mySet.add(o)) { throw 'not unique'; }

Metadata

Metadata

Assignees

Labels

area-core-librarySDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.type-enhancementA request for a change that isn't a bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions