groovy Ways of Iteration in Groovy


Groovy has more ways of looping besides supporting the Java iterations.

Groovy extends the Integer class with the step(), upto() and times() methods. These methods take a closure as a parameter. In the closure we define the piece of code we want to be executed several times.

It also adds each() and eachWithIndex() methods to iterate over collections.