void
is the keyword used in GDScript to indicate that a function doesn't return anything.
This is useful to guarantee that a function doesn't return. Note that returning null
is not the same as returning nothing. null
is a value, while returning nothing means the function doesn't give you anything back.
For example, this is not valid GDScript:
func do_nothing() -> void:
return null
To make it valid, you would need to return nothing:
func do_nothing() -> void:
pass
Or explicitly return nothing:
func do_nothing() -> void:
return
See Also
Related terms in the Glossary