Godot - Check if variable is string
GDScript code example to check if variable is string using typeof()
.
Can check if variable type is string using typeof()
in GDScript.
Check if return value of typeof()
matches "TYPE_STRING".
var text = "lemon"
if typeof(text) == TYPE_STRING:
print("It's a string")
else:
push_error("Not a string")