usertypes.lua 243 B

123456789101112131415
  1. -- Instantiate type
  2. local p = Point(13, 37)
  3. print("p =", p)
  4. -- Invoke 'scale' method
  5. p:scale(2)
  6. print("p =", p)
  7. -- Access 'x' and 'y' property
  8. print("p.x =", p:x())
  9. print("p.y =", p:y())
  10. -- Modify 'x' property
  11. p:x(10)
  12. print("p.x =", p:x())