how to accept multiple parameters from returning function in groovy

Viewed 52800

I want to return multiple values from a function written in groovy and receive them , but i am getting an error

class org.codehaus.groovy.ast.expr.ListExpression, with its value '[a, b]', is a bad expression as the left hand side of an assignment operator

My code is

int a=10
int b=0
println "a is ${a} , b is ${b}"
[a,b]=f1(a)
println "a is NOW ${a} , b is NOW ${b}"

def f1(int x) {   
  return [a*10,a*20]
}
3 Answers
Related