Groovy web console

subscribe to the feed Subscribe
to this
site
for loops and closure scope 1 (via #groovywebconsole)
tweet this snippet Tweet
this
script

for loops and closure scope 1

Published 4 years ago by Rob Fletcher
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def fns = []
for (i in (1..5)) {
    fns << {->
        println i
    }
}
fns.each { it() }