4 ms·
Also be careful about declaring variables within a case unless you explicitly introduce a block statement. Honestly the potential for mistakes using a switch a
by Kranar 6y ago
Also be careful about declaring variables within a case unless you explicitly introduce a block statement.
Honestly the potential for mistakes using a switch are so numerous that I absolutely agree with you about reflexively avoiding them and preferring the use of an if statement. The optimization benefit no longer holds on modern compilers so all you're left with is fall through to simplify some really complex branching needs.
- Cerium 6y agoAt least you get a helpful warning if you try to declare a variable without a block.