Prev | Current Page 82 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

hx:7: characters 8-38 : String should be Float
In the first example, the compiler does not register the type of the variable until it is first assigned a
value. Once the value type is determined, it then binds that type to the variable, so that only that
particular data type can be assigned to that variable in the future.
In the second example, the compiler noted that the variable had first contained a Float . It was then
assigned a String , which cannot be immediately converted to a Float type, so the compiler threw
an error.
Constant Variables
Many languages allow you to store values into variables that will remain constant, meaning that the data
contained by the variable will not, and so cannot, be modified. The purpose of providing such a facility
provides literal values with a human readable definition, allows for a central location for maintaining a
regularly used literal, and ensures that certain values are not changed throughout your application when
you know there is no reason why they should be.


Pages:
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94