The Std class contains a method called is that
allows you to perform such a check. You use it in a similar way to the cast function, only instead of
returning a newly cast value, it returns a boolean; true if the value is of the given type or false if it
isn ??™ t. Here is an example:
var isInt : Bool = Std.is( myVar, Int );
This statement would return true if myVar is an Int , or false if it ??™ s not. If the value of the variable
could be one of multiple types, then you would have to repeat the process for each type that the variable
might be.
Using Arrays in haXe
Like most languages, haXe supports grouping lists of data into Arrays and provides functionality for
managing the data held in an Array. Arrays are a very useful tool in programming, but are much more of
a rich type in haXe in terms of usability and capability, thanks to several features adopted from
functional programming philosophies. As you may have suspected, haXe Arrays are subject to typing
rules, meaning that an Array may only contain values that are of the same type, though of course, the
Dynamic type can free you of this restraint.
Pages:
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115