News for hackers. Stuff that matters.
Re:The curious case of if-not by baumandm on Thursday January 21, 2021 @04:00PM (#25864177)
The two if statements given aren't logically equivalent; an equivalent version of the 2nd one would be:

  if (!(input.command === "foo" && isValid(input))) {
    ...
  }
Which IMHO is the least comprehensible.

You can flip the negation by swapping the if/else blocks, but only if there is an else. Then you also get into questions about whether or not it matters which block is on top.

Re:The curious case of if-not by jugjug on Thursday January 21, 2021 @04:04PM (#25864214)
OP here. Yeah, I should have made it clearer, thanks.