Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Pyjong10876yI always thought it would be a great way to make state machines if you had switch(state) and continue would jump back to switch
-
@Pyjong that wouldn't be great because switch isn't supposed to be a loopy construct. However, you can easily achieve the desired behaviour with a surrounding loop.
-
Pyjong10876y@Fast-Nop that would be great! If you dont want to loop use break instead. But yeah can be done with surrounding while.
-
@Pyjong no it would be horrible because switch isn't a loop and therefore doesn't have a header/footer where the loop termination condition is checked.
What you are suggesting would be a goto right before the start of the switch, and that kind of goto use gives awful spaghetti code. You just don't use goto to jump backwards in algorithmic flow. -
Pyjong10876y@Fast-Nop well if you insist on using it wrong, then there is nothing to talk about.. peace üt
Related Rants
Somehow, a continue instead of break in a switch-case looks weird. Although it makes perfectly sense with regard to the outer for loop.
random
continue
c
switch