Does Ruby have a plain-English keyword for exclusive or, like they have ‘and’ and ‘or’? If not, is this because exclusive or doesn’t allow evaluation short-cutting?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Firstly, I don’t think shortcircuiting can sensibly apply to XOR: whatever the value of the first operand, the second needs to be examined.
Secondly, and, &&, or and || use shortcircuiting in all cases; the only difference between the ‘word’ and ‘symbol’ versions is precedence. I believe that
andandorare present to provide the same function as perl has in lines likeI think the reason for not having a
xornamed function is probably that there’s no point in a low-precedence operator in this case and that it’s already a confusing enough situation!