switch (n % 2) { case 0: trace("n is even!"); case 1: trace("n is odd!"); default: trace("I don't know!"); } // Assigning the evaluated expression to a variable var message = switch (n % 2) { case 0: "n is even!"; case 1: "n is odd!"; default: "I don't know!"; } trace(message);
Note that case
body expressions never fall through, so using the break
expression in this context isn't supported by Haxe.