I have an groove code (with some java style elements)
dates.forEach new Consumer<Period>() {
@Override
void accept(Period period) {
println period
}
}
Is it possible to do it simpler?
I would like to have something like
dates.forEach println
or
dates.forEach println date
Groovy Programming Fundamentals for Java Developers S.No. The while statement is executed by first evaluating the condition expression (a Boolean value), and if the result is true, then the statements in the while loop are executed. The for statement is used to iterate through a set of values.
Looping is an essential feature in every Programming Language including Groovy. Loops a control flow statement for traversing or iterating items in a collection, array, list, set, etc. There's a lot of ways to loop through collection, array, list, or set in Groovy.
Just use
dates.each { println it }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With