Re:Anti-If: The missing patterns (2016)
by moomin on Wednesday June 27, 2018 @07:13AM
(#17407257)
But is it easier than
? :)
[ Parent
| on HN ]
Rename 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.
Re:Anti-If: The missing patterns (2016)
by tigershark on Wednesday June 27, 2018 @08:43AM
(#17407653)
Seriously, 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...
What about:
return a ? false : b;I still prefer the Boolean logic version.
I’m a heavy user of ternary, but it’s still an “if”. And and Or are (not very much) higher-level operations.
I was being mostly facetious.