Created
April 21, 2021 11:13
-
-
Save KinoAR/7abeafc71126fec444f83fd93b86b325 to your computer and use it in GitHub Desktop.
Haxe simple example of using enums.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example of using Enums
Here's where you can test it out: https://try.haxe.org/#bf815ADc