In Groovy, I have a function that returns a triple. I'd like to:
- put the first value returned in a
Mapfor an arbitrary key and - assign the two other values to variables.
I can do:
Map m = [:]
(day, month, year) = "12 February 2014".split(" ");
m["day"] = day;
But I would like to get rid of the variable day, like this:
Map m = [:]
(m["day"], month, year) = "12 February 2014".split(" ");
For some reason it seems to be not possible. This is what the compiler alerts me about:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
/web/com/139223923319646/main.groovy: 2: expecting ')', found ',' @ line 2, column 10.
(m["day"], month, year) = "12 February 2014".split(" ");
^
Would you guys be able to either help me or explain to me why this syntax cannot be used?