Re: New switch/case idea
- Posted by jeremy (admin) Mar 31, 2009
- 1857 views
Matt:
The problem with your idea is that instead of having to type all those breaks now I would have to type all of the continues which does it make any easier.
Keep it simple, just let us turn fall through on or off.
Hey, Bernie! There are very limited uses of \\ in your message. Thank you!
The use of continue would be the exception For a switch that has fallthru turned on, you do not need continue. Here's an example:
X=1 switch X with fallthru do case 1: ? 1 case 2: ? 2 case 3: ? 3 case 4: ? 4 case 5: ? 5 break case 6: ? 6 case 7: ? 7 end switch
This switch has fallthru turned on, therefore, if you want to stop processing, then you must type break. The above example would print 1, 2, 3, 4, 5.
Now, let's say that you have a switch that has many case statements that do not need fallthru, but one or two do... Then it would be easier to:
switch X do case 1: ? 1 case 2: ? 2 case 3: ? 3 case 4 continue: ? 4 case 5 continue: ? 5 case 6: ? 6 case 7: ? 7 end switch
So, cases 1, 2, 3 do not fall thru, 4 and 5 do, then 6 and 7 do not. So, in the end we have a switch that can do just about anything easily.
Jeremy