hxcs
hxcs copied to clipboard
Fields initialization
after targeting C#, all fields initializations are moved into class's constuctor, and puts after calling constructor of super class. In most of all cases it;s fine, but here is onle example, that will not work:
class b {}
class a extends b {public var test:Int = 1;}
If class b represents some kind of deserializator (from json-type string, for example), it will initialize some fields, implemented in class a, using reflection.
so:
- constructor of class 'a' calls constroctor of class 'b'
- class 'b' deserializes data, and initializes field 'test' of class 'a'
- class 'a' replases data from field 'test' with default '1';