haxe Guards


Example

It is also possible to further restrict patterns with guards. These are defined by the case ... if(condition): syntax.

var myArray = [7, 6];
var s = switch(myArray) {
    case [a, b] if (b > a):
        b + ">" +a;
    case [a, b]:
        b + "<=" +a;
    case _: "found something else";
}

References