-
-
Notifications
You must be signed in to change notification settings - Fork 21k
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
Add an Array.pop_at()
method to pop an element at an arbitrary index
#37209
Conversation
I don't think we need an error when popping an empty array, it's not dangerous and makes a lot of sense to get a null element. Imo errors should be for consequences that are either unsafe, suboptimal (performance wise), broken, or dangerous. This scenario is probably a Warning in the worse case :b I like the idea of having a helper method instead of using |
I understand the appeal but I find the name confusing. Since we have Alternatively, we could make |
I prefer |
Indeed, it makes sense to follow |
How about |
f3f999e
to
eea410b
Compare
Array.pop()
method to pop an element at an arbitrary indexArray.pop_at()
method to pop an element at an arbitrary index
I updated the pull request to rename the new method from |
Needs to be rebased, otherwise looks good to go. |
Negative indices are supported to pop an element relative from the end.
eea410b
to
60116b1
Compare
Thanks! |
Take in mind that allowing negative indices makes things kind of inconsistent: they're allowed for |
I guess we should allow negative indices in |
master
version of #52143.Negative indices are supported to pop an element relative from the end.
Example
This closes godotengine/godot-proposals#562.
PS: Should we print an error when trying to pop an empty array, or is the current behavior fine?Edit: Not displaying an error is fine, for consistency with
pop_back()
andpop_front()
's behavior.