in reply to using Switch;
Now, now. We all have our little obsessions. What would life be like without them?
On a more serious vein (only slightly), switch statements, at least in some languages, have specialized behaviors (such as fall-through) that are not as easily replicated with a chain of if-statements. Also, a proper switch statement can make the code look a bit cleaner than the if-statement rendition of the same logic. Also, I imagine that compilers may be able to optimize a switch statement more easily than a chain of if-statements, but here I am definitely talking out of my hat.
I think ultimately it's largely a matter of preference. I haven't used a switch-like statement in years.
the lowliest monk
|
|---|