我将an array pattern matching example from the Haxe docs输入HaxeDevelop
package;
/**
* ...
* @author Terrence Brannon
*/
class ArrayMatching
{
static public function main() : Void
{
var myArray = [1, 6];
var match = switch(myArray) {
case [2, _]: "0";
case [_, 6]: "1";
case []: "2";
case [_, _, _]: "3";
case _: "4";
}
trace(match); // 1
}
}
它拒绝对Refactor的GUI调用 - >代码格式化,错误“遇到语法错误。无法格式化代码。”
然而执行
haxe.exe -main ArrayMatching --interp
产量
ArrayMatching.hx:21: 1