gdscript code example
Example 1: godot var := x
Inferred types
In most cases you can let the compiler infer the type, using :=:
var health := 0 # The compiler will use the int type.
Example 2: godot language void keyword
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
Example 3: gdscript variable
var variable = 'string'
Example 4: gdScript onready
#this variable will bw=e created when the scene tree is ready
# used for reference of node from tree
onready var timer := $Timer