class Foo { getClosure() { fun closure() { return this.toString(); } return closure; } toString() { return "Foo"; } } var closure = Foo().getClosure(); print closure(); // out: Foo