Skip to content

Commit f746639

Browse files
Update prefer-case-to-elseif.md
1 parent 717e68d commit f746639

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

docs/checks/prefer-case-to-elseif.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
Prefer `CASE` to `ELSEIF` for multiple alternative conditions because `CASE` makes it easy to see a set of alternatives that exclude each other. It can be faster than a series of `IF`s because it can translate to a different microprocessor command instead of a series of subsequently evaluated conditions. You can introduce new cases quickly, without having to repeat the discerning variable over and over again. The statement even prevents some errors that can occur when accidentally nesting the `IF`-`ELSEIF`s.
88

9+
In short: If the IF-Statement has operations (like AND, OR, …) over several variables/attributes, it is not worthwhile to revert it to a CASE-Statement. In other words, conditions on multiple variables can be left in IF-statements. Only condition(s) on single variables should be converted to a CASE-Statement.
10+
911
The threshold determines the maximum number of conditions.
1012

1113
### How to solve the issue?

0 commit comments

Comments
 (0)