Prev | Current Page 855 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

field(o, ???name???)); // where o is an instance of Person.
It will always trace to null even when getName() returns a not - empty value. This is because in this
class the name variable is just a syntax shortcut and it is not compiled in the resulting file.
The same happens in this situation:
var employee : Dynamic = new Person();
trace(employee.name);
If reflection is used in a cross - platform environment, it is important to test these functionalities on each
targeted platform individually because the reflection API makes use of low - level platform - specific calls
and some inconsistencies can possibly occur.
Chapter 16: haXe Advanced Topics
467
The Type Class
The Type class works on class definitions as the Reflect class works on object instances. Its methods,
which are also all static, are described in Table 16 - 2 .
Table 16-2
Static Method Description
createInstance(cl:Class, args:
Array) : T
Instantiates the class T using the passed arrays
as constructor arguments.
createEmptyInstance(cl:Class) : T Instantiates the class T without calling the class
constructor.


Pages:
843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867