-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch Statement Fall Thru #93
Comments
Do switch statement's cases currently fall through? it doesn't look that way, but as long as we keep that enforcement I think this wouldn't be terrible (although I'm a fan of not having to require a |
No, they don't fall through like C or Java. That's a neat idea, but the problem is that people get confused and assume they do fall through. Hence, requiring an explicit break would avoid any confusion. They also allow multiple values in a case, so most of the uses of fall through are still supported:
Kinda artificial example, but you get the idea. The above would then become:
Perhaps the last case doesn't need a Hmmmm, I agree though that the original actually does look better ... |
Ja, personally I like the first one better, and it's easier to see how you stack cases: you add N conditions separated by commas, versus allowing a fall through, and since we don't fall through by default anyway, there's no safety change. |
Suggestion: Require all switch cases are terminated with either
break
,continue
orreturn
.The text was updated successfully, but these errors were encountered: