Enum constructors can be matched using pattern matching.
Assume the following enum:
enum Color {
Red;
Green;
Blue;
RGB(r : Int, g : Int, b : Int);
}
Colours with only a green channel value can be matched as follows:
var color = Color.RGB(0, 127, 0);
var isGreenOnly = switch (color) {
// Match Green or RGB with red and blue values at 0
case Color.RGB(0, _, 0) | Color.Green: true;
case _: false;
}
Try the example on try.haxe.org.