What is type hinting?
Other popular languages such as C++, C#, Java, Golang, and Rust solve the problem of not knowing what data type a variable is by implicitly specifying what type it will carry from the moment it is defined. There is (almost) no way of defining a variable without locking it to a certain type. Also, the type of a variable, unlike in GDScript, cannot be changed over the course of a program in those other languages.
In GDScript, there is a system to do something such as this too, but less restrictive. This system is called type hinting because we give a hint of what type we would like a variable to be in. This helps GDScript to determine beforehand if an operation will work or is going to crash the game.
Let’s have a look at different ways to type hint in GDScript.
Type hinting variables
For example, if we want to specify that the player’s number of lives will always be a whole number, aka an integer, we can give a hint of this variable’...