Errrr.... NO. The problem with goto is that it breaks the execution flow. Switch doesn't do that. A switch statement is much easier to understand than an army of if statements. Aside from personal conjectures, there isn't a single argument provided against a construct that is found in every modern programming language.
It all boils down to the context that switch is used. And with the growing popularity of loosely typed languages, it's probably not a good idea to make such sweeping statements.
Agreed. There are likely cases where using a switch statement is not the optimal approah, but IMO saying that you should never use it over-generalizes.
7 comments
[ 4.4 ms ] story [ 28.7 ms ] threadI'm not sure how the existence of virtual functions makes the execution path easier to read...