haxe Enum matching


Example

Assume the following enum:

enum Operation {
    Multiply(left : Int, right : Int);
}

Enum matching can be performed as follows:

var result = switch(Multiply(1, 3)) {
    case Multiply(_, 0):
        0;
    case Multiply(0, _):
        0;
    case Multiply(l, r):
        l * r;
}

References