如果该case
块为空,则对于该特定情况不执行任何操作。所以,如果opt.colors
是'rgb'
不采取任何行动。
究其原因,提交人甚至费心包括它作为case
是因为如果他们没有,则内的代码otherwise
块(其套opts.color
到'hsv'
如果因为所提供的色彩空间未被识别的/有效的)将被执行的opt.colors
是'rgb'
,这显然是不希望行为。
该功能块等效于
if ~strcmpi(opts.color, 'rgb')
switch lower(opts.color)
case 'opponent'
% Do stuff
case 'hsv'
% Do other stuff
otherwise
% Throw warning
end
end
case
与多个值匹配的块的语法要求对case表达式使用单元格数组。
switch lower(opts.color)
case {'rgb', 'opponent'}
...
end
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句