Am 02.12.2015 um 00:17 schrieb alessio:
should work in any Groovy version. The difference here is that for this to
work we can use any class being a parent to groovy.lang.Closure plus the
class itself of course. In the case here I did not give a type, which is
equal to using the base type of all types in Java and Groovy, which is
java.lang.Object
Thanks for the clarification, this also seems to go along with what
Jason wrote before.
Could you just confirm if my previous summary below is correct then?
If so I guess I understood what 2.2 introduced ...
"So before 2.2 the cast was necessary in order to satisfy the method
signature argument-wise, with a single Object argument being the
default (and hence not requiring a cast)?"
yes
[...]
Purely from a personal point of view I'd probably stay away from sugar
coating user-level functions to mimic native language elements as in
the given example but then, I am not a language designer :)
the problem simply is that while(x, {doSomething()}) looks quite ugly ;)
On a side note: I actually strife to reduce native language elements
where it makes sense. Of course I don't want another Lisp as well. Not
that I finde Lisp bad, it is just nothing for the Java/Groovy world.
Could you please just let me know if my previous assumption below is
correct as well?
"it only works if the method expects the closure as ultimate argument.
In that case it can be appended outside, otherwise not."
if ultimate means last argument, then yes ;)
bye Jochen