groovy
groovy copied to clipboard
GROOVY-5744, GROOVY-10666: multi-assign via `iterator()` or `getAt(int)`
Support multi-assign for Stream and Iterator. Improve efficiency of multi-assign for types that do not support direct indexing like Set.
Translate "def (one,two) = rhs" into (pseudo-code):
def one, two;
{
def iter = rhs.iterator(), first;
if (iter.hasNext() && (first = iter.next()) !== rhs) {
one = first
two = iter.hasNext() ? iter.next() : null
} else {
one = rhs.getAt(0)
two = rhs.getAt(1)
}
}
https://issues.apache.org/jira/browse/GROOVY-10666 https://issues.apache.org/jira/browse/GROOVY-5744
I don't see changes from double quotes to single quotes as formatting change, nor do I see a change from {} to {->} as such a change. So where any of these changes required for this code change to pass?
On my list to look at tomorrow.
Merged. Thanks.
I'll probably revert this, I have an alternative implementation which I have spoken to Eric about but I have been too busy with ApacheCon to get my PR ready for review.
Got it.
@paulk-asert Instead of revert, can you just replace the "multiple declaration or assignment" block? There are some other fixups, including new test cases that I'd like to keep.
@eric-milles I'll see what I can do.