[ 
https://issues.apache.org/jira/browse/GROOVY-10666?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Eric Milles updated GROOVY-10666:
---------------------------------
    Description: 
Currently multiple-assignment is implemented using {{getAt(int)}}.  For types 
that support {{getAt(IntRange)}} it may be more efficient to use that 
operation.  For cases where {{getAt(int)}} is a terminal operation (aka 
streams) it may be the only way to go.

Consider the following:
{code:groovy}
Set<String> set = ['foo','bar','baz']
def (foo, bar, baz) = set // inefficient; requires 3 iterators and 6 calls to 
next

Stream<String> stream = ['foo','bar','baz'].stream()
def (foo, bar, baz) = stream // not possible because `getAt(int)` is terminal
{code}

  was:
Currently multiple-assignment is implemented using {{getAt(int)}}.  For types 
that support {{getAt(IntRange)}} it may be more efficient to use that 
operation.  For cases where {{getAt(int)}} is a terminal operation (aka 
streams) it may be the only way to go.

Consider the following:
{code:groovy}
Set<String> set = ['foo','bar','baz']
def (foo, bar, baz) = set // inefficient; requires 3 iterators and 6 calls to 
next

Stream<String> = ['foo','bar','baz'].stream()
def (foo, bar, baz) = stream // not possible because `getAt(int)` is terminal
{code}


> Implement multiple-assignment (aka destructuring) via getAt(IntRange) when 
> supported
> ------------------------------------------------------------------------------------
>
>                 Key: GROOVY-10666
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10666
>             Project: Groovy
>          Issue Type: Improvement
>          Components: groovy-jdk
>            Reporter: Eric Milles
>            Assignee: Eric Milles
>            Priority: Minor
>
> Currently multiple-assignment is implemented using {{getAt(int)}}.  For types 
> that support {{getAt(IntRange)}} it may be more efficient to use that 
> operation.  For cases where {{getAt(int)}} is a terminal operation (aka 
> streams) it may be the only way to go.
> Consider the following:
> {code:groovy}
> Set<String> set = ['foo','bar','baz']
> def (foo, bar, baz) = set // inefficient; requires 3 iterators and 6 calls to 
> next
> Stream<String> stream = ['foo','bar','baz'].stream()
> def (foo, bar, baz) = stream // not possible because `getAt(int)` is terminal
> {code}



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to