News for hackers. Stuff that matters.
Re:Anti-If: The missing patterns (2016) by d--b on Wednesday June 27, 2018 @07:10AM (#17407248)
No, but:

    if (a) return false;
    if (!b) return false;
    return true;
May be easier to read than:

    return !(a || !b);
Re:Anti-If: The missing patterns (2016) by moomin on Wednesday June 27, 2018 @07:13AM (#17407257)
But is it easier than

    !a && b
? :)
Re:Anti-If: The missing patterns (2016) by ballenf on Wednesday June 27, 2018 @10:43AM (#17408506)
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...
Re:Anti-If: The missing patterns (2016) by bena on Wednesday June 27, 2018 @10:49AM (#17408556)
What about:

    return a ? false : b;
Re:Anti-If: The missing patterns (2016) by moomin on Wednesday June 27, 2018 @01:18PM (#17409969)
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.

Re:Anti-If: The missing patterns (2016) by bena on Wednesday June 27, 2018 @01:37PM (#17410138)
I was being mostly facetious.
Re:Anti-If: The missing patterns (2016) by Sharlin on Wednesday June 27, 2018 @05:07PM (#17411875)
De Morgan laws are seriously your friends when trying to make complex boolean expressions optimally readable.