DEV Community

Discussion on: Magical Mystery XOR

Collapse
 
belevatini profile image
Rocky Bronzino

In most languages I've used, the xor operator is bitwise as well as logical xor. It doesn't make much difference for most purposes, especially with some new languages that even forbid implicit conversions to boolean. For boolean operations, it makes no difference if you use & or && for 'and' operation, and same with | or || for 'or' operation, no difference. In fact, it makes no sense to use logical && for 'a && b' when you know a is boolean, b is boolean, and you expect the result to also be a boolean. You can save a character by putting & instead of &&. Same with XOR... bitwise or logical, when operating on boolean inputs, logical and bitwise operators all behave the same way.