| |
ID | STAT-30 |
Title | Use a switch block instead of many if -elseif -else statements. |
Priority | Recommended |
Severity level | 5 |
Description | Use a switch block instead of many if -elseif -else statements when possible. |
Rationale | The notation of a switch block is more concise and therefore, more readable and easier to maintain. |
if name == "Bill"
...
elseif ismember(name, ["Judith", "Bob"])
...
elseif name == "Steve"
...
else
...
end
switch name
case "Bill"
...
case {"Judith", "Bob"}
...
case "Steve"
...
otherwise
...
end