3 ms·
That switch case transformation in the end is just syntactic sugar for the equivalent if-else-if chain so I am not sure it is actually an improvement. That sai
by ufo 7y ago
That switch case transformation in the end is just syntactic sugar for the equivalent if-else-if chain so I am not sure it is actually an improvement.
That said, I still agree with the basic idea. An if-else-if chain is easier to reason about than if-return, and representing information with enum or algebraic data type can be more robust than using a combination of booleans.
- mdpopescu 7y agoThe whole point of syntactic sugar is that it makes a code fragment easier to read / understand. That's why we're not calling it syntactic poison.