The thing with return
is that it allows you to store a value, whatever this may be, in a variable. In your example you could simply write:
func _callout():
info = _grabbing_info()
What that would do is store the output of the _grabbing_info()
function in the info
variable. In this case, info
would be a boolean value equal to either true
or false
. You can then use this info
variable as you wish.
Generally speaking, you use return
when you want the function to output a value which you wish to use somewhere else. An alternative is to use a global variable (a variable accessible from all over your code) and upate it via your functions. For example:
var info = 0
func _callout():
_grabbing_info()
func _grabbing_info():
var stuff
#doing calculations
if stuff > 10:
info = true
else:
info = false
If you don't use the return
keyword, then your function does not return any value. It just does some operations, but it does not output anything. Those functions are called void
in other programming languages, exactly because they do not output any values. I hope this clarifies things a little.