Code Corner

Jul 02, 2005 20:42

What's the difference between a series of if-else statements, and a switch statement? Before this afternoon, I had no idea.


Read more... )

Leave a comment

Comments 4

josienutter July 3 2005, 04:23:25 UTC
*golf clap*

Reply


voodoosmile July 3 2005, 10:04:08 UTC
I think it means:
Sophie = jump if arg!

Reply


epiphaniesrus July 3 2005, 18:12:24 UTC
If you ever type up a case statement that's a million lines of code long, give me a call... a padded room awaits.

Reply


Switch statements hardgeus July 4 2005, 12:06:28 UTC
There's a few weird things with switch statements, though...

A lot of times things don't behave quite like you'd expect. One thing is that you can't declare variables in any one of the cases. These days compilers catch it and won't let you do it, but I can remember running into weird behavior a few years ago.

Also, you have to manually break after every one of your cases. I can't tell you how many times I have had subtle bugs in my code that ultimately are the fault of one missing break statement causing two different cases to execute. That's a tricky one to find.

Reply


Leave a comment

Up