Closing over "this".

This commit is contained in:
Bob Nystrom
2013-12-21 15:55:08 -08:00
parent 76ac818eaf
commit 24a6f4cd8c
6 changed files with 75 additions and 18 deletions
+12
View File
@@ -0,0 +1,12 @@
class Foo {
getClosure {
return fn {
return this.toString
}
}
toString { return "Foo" }
}
var closure = (new Foo).getClosure
io.write(closure.call) // expect: Foo