4 ms·
But is it easier than !a && b ? :)
by moomin 8y ago
But is it easier than
!a && b
? :)
- tigershark 8y agoSeriously, it took me something like 10 seconds to parse your parent post. How a negated chain of if else would ever be easier to understand than a much simpler !a && b really defies my understanding...
- ballenf 8y agoRename a and b to reasonable names: a -> isAdmin b -> isActive const isDeletableUser = !isAdmin && isActive; return isDeletableUser; (Better would be naming the function "isDeletableUser" instead of the intermediate const, but was keeping with the original.) Point is for me that booleans with readable names shows how eliminating ifs becomes not only doable but arguably preferable.
- Sharlin 8y agoDe Morgan laws are seriously your friends when trying to make complex boolean expressions optimally readable.