Logical XOR (^^) operator
Currently we have bitwise
& and logical
&&, and bitwise
| and logical
||. Would it be possible to have logical
^^ in addition to the bitwise
^ for XOR?
Updated by mrkn (Kenta Murata) over 2 years ago
You can write
expr1 ^^ expr2 as
!expr1 != !expr2 in the current Ruby.
expr2 are boolean, you can write
expr1 != expr2.
^^ can be useful for the case that both
expr2 are not boolean.
Have you ever write such conditional expressions?
Updated by sawa (Tsuyoshi Sawada) over 2 years ago
||, which involve short-circuit evaluation, and hence are keywords rather than methods, the proposed
^^ will not involve short-circuit evaluation. Which is the intended proposal: as a keyword, or as a method?