How do I dynamically get a field from an object instance?
I have this code:
var reflection = reflect(this);
InstanceMirror field = reflection.getField(new Symbol(fieldName));
When I print the variable field
I get InstanceMirror on <'value of field'>
so it's all there,... but how to actually get the value?
Once you get your InstanceMirror representing the field, simply call field.reflectee
.
I found it. The actual value is in the InstanceMirror .reflectee
property.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With