DEV Community

Discussion on: Which types of loops are most popular in the programming languages you use?

Collapse
jcoelho profile image
José Coelho • Edited on

With Groovy I use closures inside the each() or eachWithIndex() methods.
You can even build the closure before hand and store it in a variable. Really cool:

Closure cl = { person ->
  println person.name
}

List<Person> people = [...]

people.each(cl)

check out my article on Groovy 😄