逆天
也可以用护罩进一步限制图案。这些是由 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";
}
也可以用护罩进一步限制图案。这些是由 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";
}