Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
peter-ahe-google opened this issue Jun 12, 2012 · 8 comments
Closed
Assignees
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. type-enhancement A request for a change that isn't a bug

Comments

@peter-ahe-google
Copy link
Contributor

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'; }

@lrhn
Copy link
Member

lrhn commented Jun 12, 2012

I agree. The Set.add method should not overwrite an existing equal value in the set, and should return true if it actually added an element to the set, and it should be documented as such.


Set owner to @lrhn.
Added Accepted label.

@dgrove
Copy link
Contributor

dgrove commented Jul 27, 2012

Issue #4210 has been merged into this issue.

@DartBot
Copy link

DartBot commented Jul 30, 2012

This comment was originally written by domi...@google.com


http://codereview.chromium.org/10836009/


Set owner to domi...@google.com.
Added Started label.

@lrhn
Copy link
Member

lrhn commented Nov 6, 2012

Issue #6548 has been merged into this issue.

@lrhn
Copy link
Member

lrhn commented Aug 22, 2013

Removed Type-Defect label.
Added Type-Enhancement label.

@kevmoo
Copy link
Member

kevmoo commented Oct 7, 2013

Another attempt: https://codereview.chromium.org/26280002/


Set owner to @kevmoo.

@kevmoo
Copy link
Member

kevmoo commented Oct 18, 2013

r28863


Added Fixed label.

@nicolasgarnier
Copy link
Contributor

Set owner to @kevmoo.

@peter-ahe-google peter-ahe-google added Type-Enhancement area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. labels Aug 28, 2014
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed type-enhancement labels Mar 1, 2016
copybara-service bot pushed a commit that referenced this issue Oct 4, 2022
Changes:
```
> git log --format="%C(auto) %h %s" ec35d46..28a2503
 https://dart.googlesource.com/pub.git/+/28a2503d Bump analyzer from 4.7.0 to 5.1.0 (#3582)
 https://dart.googlesource.com/pub.git/+/8dba9574 Crc32c checksum validation and retry of archive downloads (#3546)
 https://dart.googlesource.com/pub.git/+/27da43ec Allow `dart pub add` with existing package, update constraint instead of adding (#3570)
 https://dart.googlesource.com/pub.git/+/2e9338e5  Do resolution before publishing. (#3565)
 https://dart.googlesource.com/pub.git/+/0a487534 Migrate removed command `pub` to `dart pub` in docs & messages (#3506)
 https://dart.googlesource.com/pub.git/+/e2720c27 Fail gracefully when run inside the pub-cache (#3471)
 https://dart.googlesource.com/pub.git/+/a76c1933 Upgrade `package:tar` to 0.5.6 (#3540)
 https://dart.googlesource.com/pub.git/+/c065e559 Remove unnecessary nullability (#3547)
 https://dart.googlesource.com/pub.git/+/8e306f33 Use pub.dev in writing (#3528)
 https://dart.googlesource.com/pub.git/+/08d71024 Use unicode (if available) when drawing file-lists (#3541)
 https://dart.googlesource.com/pub.git/+/a0ca4226 Don't be conservative in upgrade --major-versions without specific pa… (#3539)
 https://dart.googlesource.com/pub.git/+/a59d890e Show file size (#3509)
 https://dart.googlesource.com/pub.git/+/b0ba5cc6 Avoid packageGraph (and therefore getExecutableForCommand) depending on the lock-file (#3533)

```

Diff: https://dart.googlesource.com/pub.git/+/ec35d46261b610e558dfd0d8525ca3fc8387b4b7~..28a2503d7f4806e6854e3ed0d783f065abfd1b5f/
Change-Id: Ia366f75da16982fb9588a0d7aa18e109daea8f8c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262346
Reviewed-by: Jonas Jensen <jonasfj@google.com>
Commit-Queue: Sigurd Meldgaard <sigurdm@google.com>
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

6 participants