diff --git a/bugpattern/TraditionalSwitchExpression.md b/bugpattern/TraditionalSwitchExpression.md index 922f909b4bf..2b70f0c5531 100644 --- a/bugpattern/TraditionalSwitchExpression.md +++ b/bugpattern/TraditionalSwitchExpression.md @@ -12,6 +12,13 @@ To make changes, edit the @BugPattern annotation or the explanation in docs/bugp --> +## The problem +The newer arrow (`->`) syntax for switches is preferred to the older colon (`:`) +syntax. The main reason for continuing to use the colon syntax in switch +*statements* is that it allows fall-through from one statement group to the +next. But in a switch *expression*, fall-through would only be useful if the +code that falls through has side effects. Burying side effects inside a switch +expression makes code hard to understand. ## Suppression Suppress false positives by adding the suppression annotation `@SuppressWarnings("TraditionalSwitchExpression")` to the enclosing element.