New issue 398 by justn...@mail.ru: .each{} returns null instead of the
object on which it is being called
http://code.google.com/p/groovypptest/issues/detail?id=398
It's inconsistent with standard Groovy and what it results in is that you
can't build up some neat groovy chains which make up the essence of the
language:
{{{[[1, 2, 3], [2, 3], [0, 2]].
each {it.remove(1)}.
collect {it + [56]}.
findAll {it.size() >= 3}}}}
In standard Groovy the above code results in `[[1, 3, 56]]`
Here's a practical example from my code, which I had to leave dynamic for
now because of this issue:
<code language="groovy">@Lazy List<Rectangle> windowRegions = {
WindowBoundariesUtils.openBoundaries(WINDOW_CONTROLS_MARKER, image).
each {WindowBoundariesUtils.updateBoundaries(TYPE1_BOUNDARY_MARKERS,
it, image)}.
collect {it.toRectangle()}.
findAll {it != null}
}(){/code>
Man.. I wanted to add a markup to the post and look what it's done to it.
And I don't have rights to edit it
I got the same result in groovy++ (http://groovypp.appspot.com/)
List l= [[1, 2, 3], [2, 3], [0, 2]]
.each {it.remove(1)} // [[1, 3], [2], [0]]
.collect {it + [56]} // [[1, 3, 56], [2, 56], [0, 56]]
.findAll {it.size() >= 3} // [[1, 3, 56]]