-
Notifications
You must be signed in to change notification settings - Fork 8
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
Please add .pop() #1
Comments
@tabatkins Would this need to pull the last one? could it pull the first? |
Don't care; authors should be treating Sets as unordered, anyway, and accept the orderedness as an accidental implementation detail we're forced to bake in. ^_^ |
For me makes sense an equal of |
So, some kind of sugar like: unshift() {
for (const item of this) {
this.delete(item);
return item;
}
} ? |
Yep. One moment - I made a typo, I mean |
Whether we name the function So yeah, if we want to return the first item, in accordance with that simple desugaring, the function should be called |
From @tabatkins on January 23, 2018 22:16
Popping from a Set/Map is actually very useful, regardless of whether there's a direction/ordering or not. The semantics are just "remove one arbitrary value from the set and give it to me", which is annoyingly clumsy to implement by hand.
I've used
.pop()
in Python several times, and felt the lack of it in JS projects.Copied from original issue: tc39/proposal-set-methods#18
The text was updated successfully, but these errors were encountered: