Re: New switch/case idea
- Posted by DerekParnell (admin) Apr 06, 2009
- 1682 views
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.
But in the same manner, when not using "with fallthru", you can use "fallthru" at the end of the case block to force the logic flow into the next case block - if that's what you really need to do.
x = 1 switch x do case 1 then procA() fallthru case 2 then procB() case 3,4 then procC() end switch
The logic flow does
- procA()
- procB()