Groovy web console

subscribe to the feed Subscribe
to this
site
TestThisInClosure (via #groovywebconsole)
tweet this snippet Tweet
this
script

TestThisInClosure

Published 9 months ago by Ashok Kallarakuzhi
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
class TestClass {
def runClosure(
    closure
) {
    def nestedClosure = { x -> 
            println "Current value of this.class.name: ${this.class.name}"
            x()}
    closure()
    nestedClosure(closure)

}
public static void main(args){
    def instance = new TestClass()
    instance.runClosure { println this.class.name}
}
}