You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As far as I have been able to find, Godot does not have an method to remove multiple elements from an array by index, and I wasn't able to find any similar discussions
I think it could be quite beneficial to be able to have a built in method to remove multiple elements from an array. This method could take a dynamic amount of indexes or an array as input and remove the elements that were at those positions from the array
the function could look like: array.remove_multiple(int ...)
adding this to the engine could make the following logic a bit cleaner and more performant
var foo:= []
func update_foo():
var to_be_removed:= []
for bar in foo:
if bar == condition:
to_be_removed.append(bar)
for item in to_be_removed:
do_stuff(item)
var i = to_be_removed.find(done)
to_be_removed.remove(i)
here is an example of what this logic could look like with the proposed changes:
var foo:= []
func update_foo():
var to_be_removed:= []
var count := 0
for bar in foo:
if bar == condition:
to_be_removed.append(count)
count+=1
for item in to_be_removed:
do_stuff(foo[item])
foo.remove_multiple(to_be_removed)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
As far as I have been able to find, Godot does not have an method to remove multiple elements from an array by index, and I wasn't able to find any similar discussions
I think it could be quite beneficial to be able to have a built in method to remove multiple elements from an array. This method could take a dynamic amount of indexes or an array as input and remove the elements that were at those positions from the array
the function could look like:
array.remove_multiple(int ...)
adding this to the engine could make the following logic a bit cleaner and more performant
here is an example of what this logic could look like with the proposed changes:
Beta Was this translation helpful? Give feedback.
All reactions