Godot Version
godot4
Question
how can I take this
arr = [a, b, c, c, d]
and turn it into this by filtering out c
[a, b, d]
godot4
how can I take this
arr = [a, b, c, c, d]
and turn it into this by filtering out c
[a, b, d]
You can use the Array.filter(method)
function for this. You would need something like this:
arr.filter(func(element): return element != c)
thnx for the help. im not quite smart enough for that though so i ended up just making a function. tysm
func filter_arr(_arr, _filter_val):
var filteredArr = []
for i in _arr.size():
if _arr[i] != _filter_val:
filteredArr.append(_arr[i])
return filteredArr
Don’t bring yourself down, you can do anything you put your mind to!
thnx the godot community is so positive
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.