Topic was automatically imported from the old Question2Answer platform.
Asked By
mdubaisi
in some methods after the brackets β()β there is a sign or what ever you call like this: " β void" so can any body help me know what does it mean?
The return type βvoidβ means that no value is returned. If we capture the return value of such a void function, it will be Null, just like when no return value is specified and no return type is specified either.
func foo() -> void:
pass
func bar():
pass
var result = some_object.foo()
print(str(result)) # will print "Null"
result = bar()
print(str(result)) # will print "Null" again
In other languages, trying to capture the return value of a void function would result in an error at compile time, but script languages can be a bit different and more flexible.
IMO using " β void:" is a way to communicate that no return value is forthcoming. You also canβt have a βreturn valueβ statement in such a function in GDScript.