You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Mark Visontai (JIRA)" <ji...@apache.org> on 2015/10/07 15:31:26 UTC
[jira] [Created] (GROOVY-7619) each() method does not iterate
properly
Mark Visontai created GROOVY-7619:
-------------------------------------
Summary: 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)