Godot Version
4.5.1
Question
In this tutorial, it talks about calling deferred code:
which I completely understand the reasoning for it. What I don’t understand is the syntax
_deferred_goto_scene.call_deferred(path)
How is a function (_deferred_goto_scene) able to call another function (call_deferred) like that? Are all methods treated as an object or Callable in gdscript? Because syntactically that’s what it looks like it’s doing.
You’re not calling a function here, but rather, getting a reference to it.
The easiest way to explain it is if you did call _deferred_goto_scene as a function, it would look like this:
_deferred_goto_scene()
but here, you do:
_deferred_goto_scene
When you don’t use parentheses, you’re not calling a function, but instead, you’re getting a reference to it. And because of that, it’s treated as a callable, and they have their own built-in methods, which includes call_deferred().
You can read more about Callables here:
1 Like
Thank you. I didn’t know that. The syntax makes sense to me now.