Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

!!a != !!b also works, but that's unwieldy.

I think maybe part of the reason is that usually you're also doing something with the value of the lhs or rhs, so you end up having to separate the cases anyway:

    if (a && !b) { frob(a); }
    else if (b && !a) { twiddle(b); }
    else { panic(); }


You don't need to double-negate,

  !a != !b
is sufficient.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: