🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
数组语法可以用来匹配多个值: > Array syntax can be used to match on multiple values: ~~~ var s = switch [1, false, "foo"] { case [1, false, "bar"]: "0"; case [_, true, _]: "1"; case [_, false, _]: "2"; } trace(s); // 2 ~~~ 这和数组匹配非常相似,但是有以下不同: > This is quite similar to usual array matching, but there are differences: * 元素的量是固定的,所以不接受不同长度的数组 * 不能捕获switch的值到一个变量,如 case x 是不被允许的(case _ 也是)。 > * The number of elements is fixed, so patterns of different array length will not be accepted. > * It is not possible to capture the switch value in a variable,i.e. case x isnotallowed(case _ still is).