3 ms·
A switch statement is just a bunch of gotos who have hurriedly put on an ill-fitting suit and tie to look respectable. Any context where you would want "if x =
by geofft 10y ago
A switch statement is just a bunch of gotos who have hurriedly put on an ill-fitting suit and tie to look respectable.
Any context where you would want "if x == this, goto here; if x == that, goto there" is a potential place to use the switch statement. Duff's device is a good example, but there are many things that can be built this way.
- dllthomas 10y ago> Any context where you would want "if x == this, goto here; if x == that, goto there" is a potential place to use the switch statement. Only if "here" and "there" are later on in the same block.