-
Notifications
You must be signed in to change notification settings - Fork 51
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
Added fall Keyword for the switch Statement #741
Conversation
Thanks for the PR, just the one question: I'm not sure I fully understand the use of the fall keyword here, what is it providing that we can't already do? |
fall is a keyword used within a switch statement to specify that execution should continue to the next case, even if the matching case block completes. In our language our switch statement is implemented to executed only first matched case block #410. In some sequential scenario you might want to execute code in one case and then continue with the next case, regardless of whether its condition matches. for example, you are managing subscriptions [ all the premium members should have premium features and basic features whereas basic members should have only basic features]
|
I think my confusion comes from the fact that if you always wanted "basic" to run you'd just move it out of the switch:
I'm trying to think of a case currently where you'd need the fall keyword without a ton of additional boilerplate |
let's consider one more case called "premium+" [ which has some more additional features to premium]. How do you handle it. |
Ah so you're saying in that circumstance you could then do something like this?
Where premium+ would fall into both cases and premium would fall into basic? |
Opinions on this @briandowns? |
I get the idea behind the addition to the language but I'm not really sure this feature is necessary. I think there are probably better ways to handle those cases. As always, I'll defer to your judgement. :D @Jason2605 |
Gonna close this out for now, thanks for the PR though @manoharkakumani |
What's Changed:
Added a new keyword fall to use it in switch statement to execute the next case in the flow
Type of Change:
Housekeeping:
Screenshots (If Applicable):