3 ms·
>Well, multiply the ifs and the elses, and you will soon find out that option 2 is much more readable and changeable, which is the more elegant solution to anyo
by Dylan16807 11y ago
>Well, multiply the ifs and the elses, and you will soon find out that option 2 is much more readable and changeable, which is the more elegant solution to anyone who's an engineer rather than a mathematician.
Disagree. In the first case I know only one block (and its parents) can execute. When all the ifs are isolated, it takes much more reading to know that only one will trigger, and that's after I make sure 'doSomething' won't change a or b.
The real way to write that is probably a switch statement.