逆天

也可以用護罩進一步限制圖案。這些是由 case ... if(condition):語法定義的。

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";
}

參考