Godot Version
4.2.1
Question
If I have an array with a bunch of random numbers, is there a way I can find out if a certain number exists in the array, and return the index number of that certain number?
4.2.1
If I have an array with a bunch of random numbers, is there a way I can find out if a certain number exists in the array, and return the index number of that certain number?
var index = your_array.find(number_to_find)
Will this return something if that number is not in the array?
yep, it’ll return -1
Thanks
For future reference, here is the documentation for Godot’s arrays.
Thanks
And if a number does exist what will it return?
The index of the first one that’s in the array
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.