Guide to the Godot game engine/Static typing

Static typing

edit

Many programming languages are static. For GDScript, it's entirely optional. Here you will learn how to make your code safer and use static typing.

Staticly typed functions

edit

Do not confuse this for static functions.

->void tells Godot the function returns nothing.

-> <type> tells Godot that the function returns <type>. This can be any Object, or any variable type.

Use nothing to hint the function can return anything.

Arguments can also be made static: argument: <type>

Statically typed variables

edit

var variable: <type> = <something or null> simple. That's it.

You can also use var variable := <something> to automatically use whatever "something" is.