-
-
Notifications
You must be signed in to change notification settings - Fork 19.2k
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 Packed*Array::pop_back
#83000
base: master
Are you sure you want to change the base?
add Packed*Array::pop_back
#83000
Conversation
This is pretty trivial, just sugar for
See here |
I'm not sure how to correctly implement |
See the implementation in Lines 665 to 674 in 6916349
Would instead involve grabbing the last value, and then resizing back |
Is there no reason we have |
Unsure, but could be because it has not been considered needed for general use of |
Note that I'd argue that having a method that just does: if not arr.is_empty():
arr.resize(arr.size() - 1) Is not needed, especially not added to a core component like |
Im skeptical if T pop_back() {
ERR_FAIL_COND(_cowdata.size() == 0);
T tmp = *_cowdata.get(_cowdata.size() - 1);
_cowdata.resize(_cowdata.size() - 1);
return tmp;
} would work with gdscript and all |
That's why it should probably error for T pop_back() {
ERR_FAIL_COND_V(_cowdata.is_empty(), T());
T tmp = *_cowdata.get(_cowdata.size() - 1);
_cowdata.resize(_cowdata.size() - 1);
return tmp;
} Alternatively write a dedicated handler for just |
I wonder if i ought to add |
I'd take that as a separate thing, also |
209461f
to
d24e5f9
Compare
closes (what i need) of godotengine/godot-proposals#4637