fork download
  1.  
  2. public function runme() {
  3. // create instance of an anonymous inner class that derives from Object
  4. var counter = new Object() {
  5. // anonymous inner classes can have variables (public, private, and so on)
  6. private var i = 0
  7. // anonymous inner classes can have constructors
  8. construct() {
  9. print("Value is " + i + " at creation!")
  10. }
  11.  
  12. // anonymous inner classes can have methods
  13. public function incrementMe () {
  14. i = i + 1
  15. print("Value is " + i)
  16. }
  17. }
  18. // "counter" is a variable containing an instance of a
  19. // class that has no name, but derives from Object and
  20. // adds a private variable and a method
  21. counter.incrementMe()
  22. counter.incrementMe()
  23. counter.incrementMe()
  24. counter.incrementMe()
  25. counter.incrementMe()
  26. }
  27.  
Success #stdin #stdout 3.45s 167468KB
stdin
Standard input is empty
stdout
Standard output is empty