Something like C++s "switch" in GenExpr?

Sym's icon

Hello, I wonder if there is a way to have something like the Switch Statements in C++ in GenExpr.

So " switch (soundtype)    { case 1: ..". Currenty I'm using stacked if and else if statements. Thank you!

Graham Wakefield's icon

Yes currently there is no switch/case so the equivalent needs to be written via if/elseif/else constructions. AFAIR the rationales for avoiding switch/case were partly that the clang compiler is intelligent enough to optimize these kinds of control flow structures to be equivalent in machine code, and partly to limit complexity of the GenExpr language.