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

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

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

Paul King commented on GROOVY-7619:
-----------------------------------

I tried your example using Groovy 2.3.5, 2.4.4 and master and all produce the expected result. Is there some grails interaction going on?

> 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
>            Priority: Critical
>
> 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)