fork download
  1. class InnerTest {
  2. static 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 #stderr 4.42s 169340KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
gw.lang.parser.exceptions.ParseResultsException: prog.gosu

Errors: 

The 'static' modifier is not allowed here. [line:26 col:5] in
line 25:         counter.incrementMe()
line 26:     }
line 27: }
Line Number: 26  Column: 5


	at gw.internal.gosu.parser.ParserBase.verifyParsedElement(ParserBase.java:292)
	at gw.internal.gosu.parser.ParserBase.verifyParsedElement(ParserBase.java:263)
	at gw.internal.gosu.parser.GosuClassParser.parseDefinitions(GosuClassParser.java:475)
	at gw.internal.gosu.parser.GosuClass.compileDefinitionsIfNeeded(GosuClass.java:1551)
	at gw.internal.gosu.parser.GosuClass.compileDefinitionsIfNeeded(GosuClass.java:1494)
	at gw.internal.gosu.parser.GosuClass.isValid(GosuClass.java:925)
	at gw.internal.gosu.parser.GosuProgram_Proxy.isValid(gw.internal.gosu.parser.GosuProgram_Proxy:2)
	at gw.internal.gosu.parser.GosuProgramParser.parseExpressionOrProgram(GosuProgramParser.java:229)
	at gw.lang.Gosu.runWithFile(Gosu.java:621)
	at gw.lang.Gosu.start(Gosu.java:140)
	at gw.lang.Gosu.main(Gosu.java:70)