Here, you simply surround the code you want to free of all type
restrictions with curly braces { and } , and head the block with the untyped keyword:
var int : Int = 0;
untyped {
int = ???Some string???;
}
Of course, although the previous example will now compile, the data contained by the variable int
following the untyped expression will vary from platform to platform. In Flash, passing a string to a
variable of type Int , even when untyped , will cause the data held by the variable to display as NaN
(continued)
Chapter 3: Learning the Basics
37
(Not a Number), while the same expression in Neko will allow the data to be safely stored, though not
very logically. There will be times when freeing your code of type restraints will save on typing many
lines of needless code, but in general, all your code should follow strict typing conventions.
Commenting Your Code
Before you start getting involved with manipulating your data, it is important to note how to
comment your haXe scripts. Commenting provides a great way for you as a developer to help remember
what your code is doing.
Pages:
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107