ANT_OPTS=-Xmx512m
. Now the code.
class DeceptiveIntegerExt {
static def minus(int self, int other) {
self + other;
}
}
Integer.mixin DeceptiveIntegerExt
assert 5 - 5 == 10
Let's explain this code: First, I create my mixin class which I named DeceptiveIntegerExt for the sheer reason that the only purpose was to overload the subtraction operator and make it add the numbers. Then I add the mixin class to the Integer class; finally I assert that my mixin works as it should, and indeed it does. Albeit that this is a VERY simple example, but I wanted to play with it.
That's all for now.
No comments:
Post a Comment