Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Introduction

This page looks at proposed changes to the Groovy language to support multiple assignment. Such support would allow for code such as:

Single Assignment

Some existing declarations involving single assigment:

Variable declarations

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:

WORK IN PROGRESS

  • No labels