Prev | Current Page 94 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

The
Dynamic type is merely a way to provide a container for data until you can reason what should be done
to that data. If you wish to convert a data type into a different type, you will need to use casting.
When using the Dynamic type, one must bear in mind that the compiler will no longer be able to
identify type violations. It is important that you maintain strong type rules and only apply functions
that you know are valid for the data contained within a Dynamic type, as failure to do so will create
unpredictable results and errors that are hard to locate.
The unknown Type
The unknown type represents type - inferred variables that have yet to be assigned a type. Once a value is
assigned to a variable of type unknown , its type will be exchanged to match that of the passed data.
Bypassing Static Typing with untyped
Sometimes you will reach a point where a large amount of untyped processing is required, and simply
piling all your data into lists of Dynamic variables will seem a messy option. Under such circumstances,
you could use an untyped block.


Pages:
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106