Iterating Over an ArrayList

We often navigate or iterate over a list of values. Groovy provides elegant ways to iterate, and to perform operations on the values as we iterate over lists.

Using List’s each Method

As we saw in Chapter 4, Using Closures, Groovy provides convenient ways to iterate collections. This iterator, the method named each, is also known as an internal iterator. For more information, see Internal vs. External Iterators.

Get Programming Groovy 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.