Sergii Sergii - 9 months ago 64
Groovy Question

How to simplify groovy loop code

I have an groove code (with some java style elements)

dates.forEach new Consumer<Period>() {
void accept(Period period) {
println period

Is it possible to do it simpler?

I would like to have something like

dates.forEach println


dates.forEach println date

Answer Source

Just use

dates.each { println it }
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download