Tuesday, March 29, 2011

Category - Simple

class MathCategory {
    static Number sin(Number self, Number add = 0){Math.sin(self) + add}
    static Number cos(Number self, Number add = 0){Math.cos(self) + add}
}

use(MathCategory) {
    println 42.sin()
    println 42.sin(1)
    println 42f.sin()
    println 42f.class.name
    println 42G.cos()
    println 42G.cos(2)
    println 42G.class.name
}

http://groovyconsole.appspot.com/script/451001

No comments:

Post a Comment