Search code examples
haxe

The code in the manual that is actually seemed to be wrong


I was learning Haxe. And I found that a code that is in the official manual doesn't be compiled in https://try.haxe.org/. and I wonder why and how to fix the code?

the code is the one in here: https://haxe.org/manual/types-enum-using.html


Solution

  • try.haxe.org assumes that the class that contains the entry point main() is called Test, while the code example you linked uses Main.

    It appears to work fine once you change class Main to class Test in the code snippet: https://try.haxe.org/#68274


    Note that some other code examples from the manual may not compile because try.haxe.org still runs Haxe 3.4.4, while the current release is 4.0.5. To work around this, people usually use this fork of try.haxe that lets you specify the Haxe version to use in the options tab:

    http://try-haxe.mrcdk.com/