Re: New switch/case idea
- Posted by DerekParnell (admin) Apr 06, 2009
- 1688 views
Fernando said...
DerekParnell said...
irv said...
OK, one more question. Without specifying "with fallthru" - i.e: using the defaults - then only the matching case will be executed, with or without a break being in there, is this correct? break can be left out?
Yes. "break" is optional if you do not have "with fallthru". If you use it, it has no effect because you don't fall through anyway.
If the break is not the last statement of the case and if it works as in C language, then break has an effect: it aborts the switch statement immediately.
- Fernando
That should still work in Euphoria too, but it doesn't at the moment. I think this is a bug. To get it to work currently you have to add a label to the break clause...
switch X label "A" do case 1 then . . . if cond then break "A" end if
</eucode>