Issue 398 in groovypptest: .each{} returns null instead of the object on which it is being called

11 views
Skip to first unread message

groovy...@googlecode.com

unread,
Sep 16, 2011, 6:55:08 AM9/16/11
to groovyp...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

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>

groovy...@googlecode.com

unread,
Sep 16, 2011, 6:59:12 AM9/16/11
to groovyp...@googlegroups.com

Comment #1 on 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

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

groovy...@googlecode.com

unread,
Sep 22, 2011, 4:01:21 AM9/22/11
to groovyp...@googlegroups.com

Comment #2 on issue 398 by gabriel....@googlemail.com: .each{} returns null
instead of the object on which it is being called
http://code.google.com/p/groovypptest/issues/detail?id=398

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]]

Reply all
Reply to author
Forward
0 new messages