Using the spread operator in method parameters
This is a great help when converting code to data:
def exec(operand1,operand2,Closure op) {
op.call(operand1,operand2)
}
def addition = {a,b->a+b}
def multiplication = {a,b->a*b}
def instructions = [
[1,2,addition],
[2,2,multiplication]
]
instructions.each{instr->
println exec(*instr)
}
Also helpful is this usage:
String locale="en_GB"
//this invokes new Locale('en','GB')
def enGB=new Locale(*locale.split('_'))