2

I typed an array pattern matching example from the Haxe docs into 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
    }
}

and it refuses a GUI call to Refactor -> Code Formatting with the error "Syntax errors encountered. Could not format code."

However executing

haxe.exe -main ArrayMatching  --interp

yields

ArrayMatching.hx:21: 1
Terrence Brannon
  • 4,760
  • 7
  • 42
  • 61

0 Answers0