You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2022/10/10 08:16:00 UTC

[jira] [Commented] (GROOVY-5744) Multiple assignment from Iterator skips every other element

    [ https://issues.apache.org/jira/browse/GROOVY-5744?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17614954#comment-17614954 ] 

ASF GitHub Bot commented on GROOVY-5744:
----------------------------------------

daniellansun merged PR #1756:
URL: https://github.com/apache/groovy/pull/1756




> Multiple assignment from Iterator skips every other element
> -----------------------------------------------------------
>
>                 Key: GROOVY-5744
>                 URL: https://issues.apache.org/jira/browse/GROOVY-5744
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-runtime
>    Affects Versions: 2.0.5
>            Reporter: Justin Piper
>            Assignee: Eric Milles
>            Priority: Minor
>
> If you try to assign multiple variables from an iterator Groovy will skip every other value.
> Example:
> {code}
> final list = [1,2,3]
> final iter = list.iterator()
> final def (a,b,c) = list
> final def (d,e,f) = iter
> assert "$a $b $c" == "$d $e $f"
> {code}
> Result:
> {noformat}
> Assertion failed: 
> assert "$a $b $c" == "$d $e $f"
>          |  |  |  |    |  |  |
>          1  2  3  |    1  3  null
>                   false
> {noformat}
> The expected behavior is either that the assertion succeeds, or the assignment to (d,e,f) fails outright.
> If this is fixed it would also be nice if any Iterable could be used on the RHS.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)