Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

We should consider breaking out of a closure using some language syntax.

Code Block
[1, 2, 3].each { 
  println(it)
  if (it == 2)
    break 
}

would print

Code Block
1
2

At the implementation level it could be that 'break' really just throws a ClosureBreakException which the each() method could catch to terminate the loop.