Comment Re:Else ifs - yuck (Score 2) 399
To expand upon your final point: The real reason to use switch vs else-if is in what you communicate to other programmers.
Switch communicates that you're evaluating exactly one variable/operation. Else-if towers can mix and match the evaluation criteria. Programmers who choose an else-if tower for evaluating the same variable all the way through are just inviting trouble in the future, when someone comes along and adds an additional clause to one of the evaluations and screws the whole thing up.
Oh also, some compilers have a maximum number of else-if conditions. I worked at a company that created a huge else-if tower which eventually grew too large and broke MSFT's cl. We quickly rewrote the code as a hashtable (which is what it should have been anyway).