Quantcast
Channel: Spring Community Forums - Grails
Viewing all articles
Browse latest Browse all 40

Mysterious behavior in looping over collection. Iteration count less than size

$
0
0
Again i have a mysterious behavior in my application:
Code:

def users = v.user
println "Class: "+users.getClass()
println "Size: "+users.size()
println "Users: "+users
users.each{
        println "User: " + it.login
}

Output:
Quote:

Class: class java.util.ArrayList
Size: 4
Users: [ittutorium.User : 1, ittutorium.User : 1, ittutorium.User : 1, ittutorium.User : 1]
User: test
There are four users in the list (four times the same) but the each only iterates over one. How could this be ?

Viewing all articles
Browse latest Browse all 40

Trending Articles