Last changed: Oct 03, 2007 14:07 by
Terence Parr
Awesome. Mantra does a dynamic mixin. Just map a string to a closure with "self" as first arg:
int.mixin("toHex",
{int self | return java {new mstring(Integer.toHexString(((mint)self).v))};}
);
println(32.toHex());
also note you could alter the MetaClass per object (set .class field) to alter behavior per instance! You can ask about meta object now:
To avoid strange bugs, you can only add not override/alter behavior.