fork download
  1. class Person {
  2. var _name : String // backing field
  3.  
  4. // Property for Name
  5. property get Name() : String {
  6. return _name
  7. }
  8.  
  9. property set Name(value : String) {
  10. _name = value
  11. }
  12. }
  13.  
  14. function main() {
  15. var person = new Person()
  16. person.Name = "Alice" // Using the setter
  17. print("Person's Name: ${person.Name}") // Using the getter
  18. }
Success #stdin #stdout 3.45s 170356KB
stdin
3
2
hi
4
sdfsdf
3
asdf
stdout
Standard output is empty