Fields in closures.

This commit is contained in:
Bob Nystrom
2013-12-23 11:17:40 -08:00
parent c0169896e6
commit 9235a7e38f
7 changed files with 128 additions and 23 deletions
+16
View File
@@ -0,0 +1,16 @@
class Foo {
new { _field = "Foo field" }
closeOverGet {
return fn { return _field }
}
closeOverSet {
return fn { _field = "new value" }
}
}
var foo = new Foo
IO.write(foo.closeOverGet.call) // expect: Foo field
foo.closeOverSet.call
IO.write(foo.closeOverGet.call) // expect: new value