Godot 4.0
I was experimenting with variables of which types were static. I found that for some reason I could still change the type. For example, if the static variable was an integer, i could change it to a float and not receive an error and the code would work fine. However, if the static variable was an integer and I changed it to a string, the code would give me an error and would not work. Why is this?
CHANGING STATIC VARIBALE TO FLOAT:
extends Node
var test := 15
func _ready():
test = 15.5
print(test)
OUTPUT:
CHANGING STATIC VARIABLE TO STRING:
extends Node
var test := 15
func _ready():
test = "hi"
print(test)
OUTPUT:
Parse Error: Cannot assign a value of type “String” as “int”.