groovy Ways of Iteration in Groovy

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Introduction

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.



Got any groovy Question?