This page looks at proposed changes to the Groovy language to support multiple assignment. Such support would allow for code such as:
Some existing declarations involving single assigment:
In order to not conflict with existing definitions, any variable declaration which wishes to make use of multiple assignments must surround the 'tuple' of variable declarations in round brackets. Whenever such a round bracket is found, the compiler will match the tuple with a list. The list will be expected to be where it would be in the case of single assignment. The compiler will 'unpack' the list into the tuple of variables.
Nested variations are also supported:
Differing sized tuples and lists are catered for by ignoring extra list members and leaving any untargeted variables in the tuple set to null:
There can be at most one [at the end like varargs?] 'tuple spread' operator which takes the rest of the list:
Setting a bunch of variables to the same (or related) values is accomplished using normal list conventions:
WORK IN PROGRESS