>
> In our projects, we have style checks that suggest "for (x in y) ..." over
> "for (T x : y) ...". The "in" form is groovy idiom and the ":" form is for
> java compat. Switching to use "y.each { x-> ... }" or "y.forEach(x ->
> ...)" is a personal preference. Note: the debugger steps through t
Hi OC,
regarding return statements working "as expected" inside loop/if
statement body like Closures:
1. As I said I already proposed Groovy support this here a few years back.
2. It never came to fruition, with all of the problems (besides someone
needing to do the actual coding) revolving
Hi OG,
oh my, you opened a can of worms there - I know what I am talking about,
since I opened it already a few years back ;-)
Replying to the easy part first:
1. Support for "in" is, if memory serves, a relative new addition to
Groovy.
1. I agree that it is quite intuitive in Groovy,
On 04.12.24 18:03, OCsite wrote:
[...]
A trivial (and most probably very very wrong and problems-inducing!)
approach might perhaps be an ASTT which would convert code like
def foo() {
bar.each { if (it) methodreturn it }
}
to something like
def foo() {
try {
bar.each { if (it) throw
:02 PM
To: Groovy_Developers
Cc: Milles, Eric (TR Technology)
Subject: Re: [EXT] for loops, returns, and other animals
Miles,
On 4. 12. 2024, at 18:21, Milles, Eric (TR Technology) via dev
wrote:
... Switching to use "y.each { x-> ... }" or "y.forEach(x -> ...)"
d to Groovy or not, regardless the particular implementation (perhaps I
should not have added the exception-based example at all).
Thanks and all the best,
OC
>
> From: OCsite
> Sent: Wednesday, December 4, 2024 11:03 AM
> To: dev@groovy.apache.org
> Subject: [EXT] for loops, r
It may not be the final form of your solution, but does let you try
things quickly.
From: OCsite
Sent: Wednesday, December 4, 2024 11:03 AM
To: dev@groovy.apache.org
Subject: [EXT] for loops, returns, and other animals
External Email: Use caution with links and at
> For one, I would argue that the native and groovier (since more logical
> and intuitive and intention-revealing for anyone who can read English
> completely regardless whether he knows Java or not) variant should be the
> *for/in* loop, like *for (foo in foos)*. That weird and unintuitive colon
>
MG,
> On 4. 12. 2024, at 16:11, MG wrote:
> e.g. using a for(foo : foos) { ... } loop instead of canonical Groovy
> foos.each { foo -> ... }, to be able to easily return from the for body from
> multiple places using return statements.
For one, I would argue that the native and groovier (since