Variable declaration and scope
Understanding how variable declaration is done and its scope is very important.
Declaring a variable
You can declare a variable by using the var
keyword followed by the name of the variable. There are two syntaxes to declare a variable: one is to declare variables at class level, and another one is to declare local variables in blocks of instructions (inside functions, for example).
At class level
The following is the syntax you can use to declare a variable at the class level:
[public|private]
[static]
var varName
[:
varType]
[=
someValue];
Note that if you don't specify public
or private
, all members will be private unless the class implements the Public
interface.
Static variables are variables that will be stored ...
Get haXe 2 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.