Assigning types to parameters

Just wanted to add that you can specify type in GDScript so the compiler will let you know if you are trying to pass the wrong variable type. You do this like so:
func add_floats(num1: float, num2: float):
var result = num1 + num2
return result

So if you then tried to call add_floats(“4.9”, 2.3), it should warn you.

1 Like

Privacy & Terms