Skip to content

Instantly share code, notes, and snippets.

@KinoAR
Created April 21, 2021 11:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KinoAR/7abeafc71126fec444f83fd93b86b325 to your computer and use it in GitHub Desktop.
Save KinoAR/7abeafc71126fec444f83fd93b86b325 to your computer and use it in GitHub Desktop.
Haxe simple example of using enums.
enum Direction {
Left;
Right;
Up;
Down;
}
function main() {
currentDirection(Left);
currentDirection(Right);
currentDirection(Up);
currentDirection(Down);
}
function currentDirection(direction:Direction) {
switch (direction) {
case Left:
trace('facing left');
case Right:
trace('facing right');
case Up:
trace('facing up');
case Down:
trace('facing down');
}
}
@KinoAR
Copy link
Author

KinoAR commented Apr 21, 2021

Example of using Enums

Here's where you can test it out: https://try.haxe.org/#bf815ADc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment