The default statement is optional and is similar to the else state-
ment used with if statements. I normally implement a switch
statement when I know that a procedure will be passed only
pre-specified values through arguments. I normally reserve if state-
ments for performing tests, especially when the value tested could
be an unknown value. This is, however, a matter of personal choice
and a subject of heated discussion amongst nerds.
Lastly, remember to include the break command to avoid fall-
ing. “Falling” occurs when the
break command is left out, which
causes MEL to continue on and evaluate the next case statement
(and so on) until reaching either a
break command or the end of the
switch statement altogether. Omit the
break command and the case
statement that is called will continue on to the next case statement
string $s = "bye";
print "Nice to meet you!";
print "Take care...";
print "Excuse me?";
The Script Editor prints back:
Take care...Excuse me?
Maya doesn’t know when to stop after the second case statement
and falls right through to the default statement, executing it as well.
The last condition in a switch statement, whether it is a case or
default statement, doesn’t require a
break command, but it is good
practice to add one anyway.
Scene Management with ewc_extendedLayerManager