10.2.1 Примечания для программиста C
Оператор switch также доступен в широко используемом языке программирования C. Однако есть некоторые различия между оператором в Octave и C
- Случаи являются исключительными, поэтому они не «проваливаются» так, как в операторе
switchязыка C. - Элементы command_list не являются необязательными. Сделать список необязательным означало бы требовать разделитель между меткой и списком команд. В противном случае вещи вроде
switch (foo) case (1) -2 …
привели бы к неожиданным результатам, как и
switch (foo) case (1) case (2) doit (); …особенно для программистов C. Если
doit()должно выполняться, если foo равно либо1, либо2, код выше следует писать с использованием массива ячеек, подобного этомуswitch (foo) case { 1, 2 } doit (); …
© 1996–2022 The Octave Project Developers
Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.
Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions.
https://docs.octave.org/v5.2.0/Notes-for-the-C-Programmer.html