Use switch blocks

IDSTAT-30
TitleUse a switch block instead of many if-elseif-else statements.
PriorityRecommended
Severity level5
DescriptionUse a switch block instead of many if-elseif-else statements when possible.
RationaleThe notation of a switch block is more concise and therefore, more readable and easier to maintain.

Avoid:

if name == "Bill"
    ...
elseif ismember(name, ["Judith", "Bob"])
    ...
elseif name == "Steve"
    ...
else
    ...
end

Instead use:

switch name
    case "Bill"
        ...
    case {"Judith", "Bob"}
        ...
    case "Steve"
        ...
    otherwise
        ...
end