How to simplify groovy loop code

Sergii :

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
tim_yates :

Just use

dates.each { println it }

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=465628&siteId=1