3 ms·
Also, it's not really removing the `if`, it's just making it into `&&` and `||` instead, which are shorthand conditionals anyways. So a bit misleading to call t
by diggan 8y ago
Also, it's not really removing the `if`, it's just making it into `&&` and `||` instead, which are shorthand conditionals anyways. So a bit misleading to call this a anti-if strategy.m
- pure-awesome 8y agoFair point. It's basically syntactic sugar. Hard to say how to properly refactor out the if statements without knowing the problem domain. And I guess that's basically the point - using if statements means that you are writing imperative code rather than modelling the problem. You are specifying to the compiler how you want things done, rather than what it is that you want done.
- pythonaut_16 8y agoIf you have a function that's using if statements to decide which boolean to return, it's almost always better to return the expression directly. `if (foo) { return true } else { return false }` is the same as `return boolean(foo)`