Files
wren/test/language/field/use_before_set.wren
T

11 lines
260 B
Plaintext
Raw Normal View History

2013-11-23 14:55:05 -08:00
class Foo {
2015-09-01 08:16:04 -07:00
construct new() {}
2015-09-15 07:46:09 -07:00
write { System.print(_field) } // Compile a use of the field...
2013-11-23 14:55:05 -08:00
init { _field = "value" } // ...before an assignment to it.
}
2015-07-10 09:18:22 -07:00
var foo = Foo.new()
2013-11-23 14:55:05 -08:00
// But invoke them in the right order.
foo.init
foo.write // expect: value