hi Guys,
Just started learning Haxe so I might made a childish mistake :) Thanks for all the help in advance!
Doc says if a variable was not found in a class which implements "Dynamic", logic falls back to call "resolve(field:String)" function (if implemented).
I wanted to test it and it seems "resolve(field:String)" is called even if variable exists, which means, I cannot retrieve/use the value I stored previously.
Please explain why or let me know if it's a bug so I can report it. Thank you in advance!
The code below is 95% of docs sample. I added my part at Foo.main(), also commented those lines
class Resolve implements Dynamic<String> {
public var present:Int;
public function new() {}
function resolve(field:String) {
return "Tried to resolve " + field;
}
}
class Foo {
static public function main() {
var c = new Resolve();
c.present = 2;
c.uncleFoo = "hehehe"; //OK as no error
trace(c.present); //OK as
result is fine
trace(c.uncleFoo); //NOK! Falls back to call resolve - Why???
//c.uncleFoo = 103; //OK as error: "Int should be String" == variable exists
}
}
compile/run:
Call [path][\ | /]haxe.exe -main Foo --interp
result:
Foo.hx:14: 2
Foo.hx:15: Tried to resolve uncleFoo
line 14 is OK, but line 15 should be "hehehe", doesn't it?
If not, how am I supposed to use the string value I stored in object "c" (of class Resolve)?
Thank you again!
All the Best,
Mark