Gdscript automatically assigns a value to a variable when it specifies its type

I found something interesting in gdscript.

image

2 Likes

I believe this is due to the fact GDScript doesn’t have nullable types. For example var s: String = null generates an error.

Possibly some more info

1 Like

You should be getting warnings about this though:

The variable "a" was used but never assigned a value.
  <GDScript Error>UNASSIGNED_VARIABLE
1 Like

If you want the office explaination.

Built in types are passed by value, and null isn’t a value.

Everything else can be passed by reference, and can have a null reference.

2 Likes