1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
class Foo { getClosure() { fun f() { fun g() { fun h() { return this.toString(); } return h; } return g; } return f; } toString() { return "Foo"; } } var closure = Foo().getClosure(); print closure()()(); // expect: Foo