You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Pascal Schumacher (JIRA)" <ji...@apache.org> on 2015/10/09 18:24:26 UTC

[jira] [Closed] (GROOVY-7619) each() method does not iterate properly

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

Pascal Schumacher closed GROOVY-7619.
-------------------------------------
    Resolution: Invalid

> each() method does not iterate properly
> ---------------------------------------
>
>                 Key: GROOVY-7619
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7619
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.3.7
>         Environment: OS: Windows 7
> Grails: 2.4.4
> JDK: 1.8.0_31
>            Reporter: Mark Visontai
>
> it seems the each method is erroneous. For the code:
> {code}
> def xml = new XmlSlurper().parseText('''
> <list>
>     <item a="1">a</item>
>     <item a="2">b</item>
>     <item a="1">c</item>
> </list>
> ''')
> xml.'**'.findAll { it.@a=='1' }.each {
>     println "hi"
> }  
> {code}
> |{code: title=Expected output:}
> hi
> hi
> {code}|{code: title=Actual output:|bgColor=#fcc}hi{code}|
> Two result items are only provided if I also print something that is changing between the iterations, eg. a variable with increasing value, like
> {code}
> def i=0
> xml.'**'.findAll { it.@a=='1' }.each {
>     println "hi" + i++
> }  
> {code}
> what can be the reason?
> Thanks,
> Mark



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)