class Person var _age as int pro ageProp as int get return _age set _age = value # use 'from' as a shorthand form for the above: pro age from var # var is the preferred form when the variable name is the same (but with an underscore) pro age1 from _age # and use 'get' and 'set' in place of 'pro' when appropriate: set age2 from _age get age3 from _age # can still use a doc string: get age4 from _age """ An example. """ shared def main .testPerson .testPoint PublicVar().check def testPerson p as Person = Person() p.ageProp = 5 assert p.age==5 p.age1 = 6 assert p.age1==6 p.age2 = 7 assert p.age3==7 p.age = 8 assert p.age==8 def testPoint p as Point = Point() assert p.x == 0 and p.y == 0 p.moveBy(2, 3) assert p.x == 2 and p.y == 3 class A get foo as int return 1 class B inherits A var _foo as int get foo from var is override class C get foo as int return 1 class D inherits C var _foo as int get foo from var is override class Point # TODO: cover `pro` and `set` # TODO: verify _x is protected and __y is private cue init base.init _x = 0 __y = 0 get x from var as int # typical property with matching var backing get y from __y as int # test explicit naming of the var. note that __y will be private def moveBy(dx as int, dy as int) _x += dx __y += dy class PublicVar var foo as int get bar from foo def check assert .foo == 0