Groovy web console

subscribe to the feed Subscribe
to this
site
closure in for loop (via #groovywebconsole)
tweet this snippet Tweet
this
script

closure in for loop

Published 2 weeks ago by Roman
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def strings = ['one', 'two', 'three']
def closures = []

for (str in strings)
  closures << { println "closure over string: $str" }

closures.each { it() }