The switch
statement is also available in the widely used C
programming language. There are, however, some differences
between the statement in Octave and C
switch
statement of the C language.
switch (foo) case (1) -2 ...
would produce surprising results, as would
switch (foo) case (1) case (2) doit (); ...
particularly for C programmers. If doit()
should be executed if
foo is either 1
or 2
, the above code should be
written with a cell array like this
switch (foo) case { 1, 2 } doit (); ...