Re:The Three Ways of XOR
by andreareina on Monday February 13, 2017 @02:38AM
(#13633721)
!!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(); }
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: