|
Author |
Topic: case(val) { } (Read 419 times) |
|
Markavian
|
case(val) { }
« on: Apr 16th, 2004, 4:12pm » |
|
Any plans to include the 'case() { }' syntax? I found myself typing it once when dealing with keyboard inputs, then having to revert to a big sequence of if/else statements case(int val) { 1: 2: 3: print "1 to 3"; break; 4: 5: 6: print "1 to 6"; break; default: print "I have no code for that value"; } I know its not everyone's favourite way of programming, but its a useful way of formatting certain types of code.
|
|
|
|
fry
|
Re: case(val) { }
« Reply #2 on: Apr 16th, 2004, 5:47pm » |
|
case 0: s++; should usually be: case 0: s++; break; otherwise all the cases will run together, fwiw (only posting correction since someone elsewhere on the board just ran into trouble with this..)
|
|
|
|
mohn
|
Re: case(val) { }
« Reply #3 on: Apr 17th, 2004, 4:44am » |
|
thank you for the correction ... 7:00am and the coffee was still a brewin...
|
|
|
|
Markavian
|
Re: switch() { }
« Reply #4 on: Apr 18th, 2004, 2:39am » |
|
my bad, faulty memory. switch(value) { case 1: s++; break; case 2: i++; break; default: print "lly."; } thanks all the same. I'll know for next time. (doh)
|
« Last Edit: Apr 18th, 2004, 2:41am by Markavian » |
|
|
|
|
|