Best 'switch/case' replacement in unity JS is...

Trying to do this (set obj rotation for which side of a cube is facing forward) :

			case "b": case "h":	 case "n": case "t": case "z":  
				 x = 270.0; y = 180.0; z = 0.0;
				break;
				

	                       case "f": case "l":  case "r": case "x":  {
				 x = 90.0; y = 180.0; z = 180.0;
				break;

but Unity can’t handle that. I really don’t want 26 “if” statements; “in” doesn’t seem to work…

What is “the Unity Way” for such selections, where multiple conditions produce the same result?

TIA

The best switch/case replacement is switch/case:

var foo = "a";
switch (foo) {
    case "a":; case "b":; case "c":
        print ("One");
        break;
    case "d":; case "e":; case "f":
        print ("Two");
        break;
    default:
        print ("None");
}

–Eric

Thanks, Eric. Never saw the semi-colon used that way in JS before…

Is there a good reference for Unity’s version of JS?

Thanks again.

There’s a good JS resource in this thread.

Thank you. That lead me to:

which does explain the differences between standard and Unity JS.