Skip to content

Commit

Permalink
Add TraditionalSwitchExpression.md.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 654138846
  • Loading branch information
eamonnmcmanus authored and Error Prone Team committed Jul 19, 2024
1 parent 8e1bd10 commit 053f721
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/bugpattern/TraditionalSwitchExpression.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
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.

0 comments on commit 053f721

Please sign in to comment.