Unable to iterate on object of type 'callable'

Godot Version

4.4

Question

I have been working on a system within Godot to manage text dialogue. I have implemented a function as follows:


This searches for a specific string within the given array and returns the index of the array.
However, when I run the code I get the following error:
image
After looking online I have found questions on errors for iteration on other types such as ‘object’ but not on ‘callable’.
Any help would be greatly appreciated thanks !

var size = array.size should be var asize = array.size()

What your line of code does is assign the function array.size to asize.

To prevent errors like this, consider using static typing. i.e.

var asize : int = array.size()

Try removing the parenthesis from the line of code above. Godot will immediately warn you about a type mismatch without having to run your code.

e: also, please paste your code as text instead of images. You can preserve formatting by putting three backticks (```) before and after your code.

1 Like

Thank you so much! I’ll make sure to paste code in future

1 Like