groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alessio <>
Subject Re: "External" closures, why?
Date Tue, 01 Dec 2015 19:56:58 GMT
On Tue, Dec 1, 2015 at 5:44 PM, Jochen Theodorou <> wrote:
> The syntax is not new, Groovy had this kind of "attached block" since pre Groovy 1.0

Alright, I did just run the code with against 2.0 (which was supposed
not to support it) and it ran just fine.

But then, what does the documentation refer to when it says one can
omit an explicit coercion as of 2.2?

> This kind of block usage w

Something is missing here.

On Tue, Dec 1, 2015 at 5:58 PM, Owen Rubel <> wrote:
> Maybe I can help a little...

Thanks, appreciated!

> This is especially useful if it is something like a method call that only
> gets called once. Why create a method for it? Just use a closure. :)
> Closures provide tons of convenience over methods. They are not meant to
> replace them at all but act as a convenience method

In my understanding that is just a function pointer (good old C :) )
or - if one likes it better - an anonymous function or - if someone
likes the Java term better :) - a lambda.

So far so good, the concept itself is not that much of a problem, the
thing that I was simply wondering (and which confused the heck out of
me :) ) is the choice to support mentioned form of passing the
closure, which IMVHO could be utterly confusing, as the passed
function is VISUALLY not part of the function call but "dangling"
somewhere near it.

Thanks again!

View raw message