Switch Statement Fall-Through
August Nagro
augustnagro at gmail.com
Mon Nov 4 23:18:37 UTC 2019
Hi!
I recently read Stephen Colebourne’s blog on the new switch syntax (https://blog.joda.org/2019/11/java-switch-4-wrongs-dont-make-right.html), and although I don’t agree with the proposed solution, his issue with the new switch falling-through is spot-on.
I've personally used fall-through switch statements, but I think they should only ever be applicable to the old-style switch. Having the compiler enforce this will prevent a lot of misuse and confusion. Instead of four types of switch, there is only two:
1. switch with only ->, that doesn't fall-through, checks exhaustiveness, has yield, commas between cases, and can be used as an expression.
2. switch with only :, the standard switch.
Sincerely,
August Nagro
More information about the amber-dev
mailing list