mirror of
https://github.com/wren-lang/wren.git
synced 2026-01-11 22:28:45 +01:00
A property is a field with an implicit getter, setter, and optional class body initializer. It's handy for defining publicly visible state in a class. When modules are classes, this is needed for "top level" variables. Right now, a class var gets both a getter and setter. It would be nice to also have something like "val" for properties that are publicly visible but not settable. Also, still need to support "static var" for metaclass properties.
13 lines
254 B
Plaintext
13 lines
254 B
Plaintext
class Foo {
|
|
construct new() {}
|
|
var bar
|
|
}
|
|
|
|
var foo = Foo.new()
|
|
System.print(foo.bar) // expect: null
|
|
System.print(foo.bar = "value") // expect: value
|
|
System.print(foo.bar) // expect: value
|
|
|
|
// TODO: Duplicate.
|
|
// TODO: static var.
|