Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

@KinoAR 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