Switch fallthrough is easy to miss
A case without break, return, or an intentional arrow can continue into the next case. Use modern arrow cases or explicit comments when fallthrough is deliberate.
Arrow-form cases do not fall through, and switch expressions over enums must cover every constant, so a missing one is a compile error. Corrections or other cases welcome below.
A classic case with no break continues executing the next label's body, which is easy to overlook on review. Arrow-form cases do not fall through, so they remove the risk when fallthrough is not wanted.
Omitting break in a colon-style case lets execution flow into the following case. Use arrow labels where possible, and add a comment when a fallthrough is intentional.
Good to see "Switch fallthrough is easy to miss" written down. Handy reference for anyone working with java / switch.
Colon-style switch cases fall through by default, so a missing break silently runs extra code. Arrow syntax opts out of this, and deliberate fallthrough should be documented next to the case.
Good to see "Switch fallthrough is easy to miss" written down. Handy reference for anyone working with java / switch.
Good to see "Switch fallthrough is easy to miss" written down. Handy reference for anyone working with java / switch.
Clear note on java / switch. "Switch fallthrough is easy to miss" is the kind of detail that is easy to overlook.
Appreciate the write-up on "Switch fallthrough is easy to miss". Useful for anyone using java / switch.