In this chapter, you will learn about the typing system. haXe is a strongly typed language but provides quite a lot of features such as type inference and Dynamic objects.
haXe has a typing system, which offers a lot of features. Understanding these features is very important to write and debug your programs. It will also help you make the most out of haXe.
In this chapter, we will:
Talk about explicitly typed variables
Talk about function's type.
Learn what type inference is
Learn how to cast variables
Learn about type parameters
See what type parameters are used for
How you can use them with already created types
How you can create a type that makes use of them
Create an example
All of these points are fairly easy to understand and we are going to illustrate them in several exercises.
Explicitly typed variables
Variables are explicitly typed if you write their type while declaring them. This is what we have seen so far; and this is done in the following way:
var myVar : TypeOfMyVariable
This way, you tell the type of your variable to the compiler.