Prev | Current Page 78 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

For now, however, it is better to acknowledge that as haXe is statically typed,
it is optimal in terms of speed and size, and the tidy syntactical requirements can only help in making
you a better programmer.
Needless to say, static typing requires variable declarations. Variables in haXe need to be declared before
they can be used so that an appropriate structure and memory allocation can be reserved for your data.
You declare variables using the following syntax:
var varName : Type;
The keyword var is similar to Visual Basic ??™ s Dim keyword, which tells the compiler that the following
line will be a variable declaration. Without the var keyword, the compiler will expect an expression to
follow such as an assignment of data into the variable, which of course will result in a compiler error, as
the variable is not yet declared.
Following the var keyword is the name or label of the variable. You can label your variables anything
you like, as long as the variables contain only letters, numbers, or the underscore ( _ ) character.


Pages:
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90