Prev | Current Page 98 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

In order to do this, you need to use casting.
In truth, casting in haXe does not literally convert the data as it would in C++, for example, but instead
performs an unsafe allocation of data from a source value to a variable.
Those of you who program with C++ or Java will be very familiar with casting, which involves tagging
the type you wish to return to the variable or value, like this:
double myDbl = (double) 44;
Here, the literal integer 44 is converted to a floating - point number before being stored in the variable
myDbl . The cast is valid as the data types are of a similar nature, though custom parsing routines are
necessary when dealing with more complex data conversions. In haXe, however, the variable is allowed
to contain whichever data you like, in essence, though the compiler will expect the variable to provide
the same functionality throughout its lifetime regardless of the data it contains.
The cast Function
haXe supplies a similar method to C/C++ casting in the guise of the cast function.


Pages:
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110