Is there no XOR operator for booleans in golang?
I was trying to do something like b1^b2
but it said it wasn't defined for booleans.
Is there no XOR operator for booleans in golang?
I was trying to do something like b1^b2
but it said it wasn't defined for booleans.
With booleans an xor is simply:
In this context
not equal to
performs the same function asxor
: the statement can only be true if one of the booleans is true and one is false.There is not. Go does not provide a logical exclusive-OR operator (i.e. XOR over booleans) and the bitwise XOR operator applies only to integers.
However, an exclusive-OR can be rewritten in terms of other logical operators. When re-evaluation of the expressions (X and Y) is ignored,
Or, more trivially as Jsor pointed out,