Re: New switch/case idea
- Posted by DerekParnell (admin) Apr 06, 2009
- 1648 views
irv said...
switch op with fallthru do case RETURNT then opRETURNT() break case RHS_SLICE then opRHS_SLICE() break
Just so I understand: If I remove or forget the break after opRETURNT(), then regardless of whether RHS_SLICE is or isn't valid, opRHS_SLICE() gets executed, correct?
Yes that is correct. This is how the "switch" statement works in C/C/C#/D and a few other programming languages. That is also the reason why we chose to make the default Euphoria switch different from C/C. In Euphoria, you have to explicitly tell it to enable falling through.