Dynamic method invocation
You can invoke a method using a string with its name
class Dynamic {
def one() { println "method one()" }
def two() { println "method two()" }
}
def callMethod( obj, methodName ) {
obj."$methodName"()
}
def dyn = new Dynamic()
callMethod( dyn, "one" ) //prints 'method one()'
callMethod( dyn, "two" ) //prints 'method two()'
dyn."one"() //prints 'method one()'