Re: switch bug?
- Posted by Switch Select Jul 20, 2008
- 882 views
[quote Jeremy Cowgar]
irv said...
switch result do case 0 : puts(1,"Quit button clicked\n") case 1 : puts(1,"OK button clicked\n") case -4 : puts(1,"You closed the window\n") case else ? result end switch
Just a note, however, you do have a slight problem in your code. Case statements will fall through.
You need to introduce break at the end of each case:
switch result do case 0 : puts(1,"Quit button clicked\n") break case 1 : puts(1,"OK button clicked\n") break case -4 : puts(1,"You closed the window\n") break case else ? result end switch
Can we also have the select statement, that doesn't fall through.