关键字为独占或红宝石? [英] Keyword for exclusive or in ruby?

查看:136
本文介绍了关键字为独占或红宝石?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

红宝石是否有纯英文关键字为独占或像他们有与和或?如果不是,这是因为独家或者不允许评价短切?

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?

推荐答案

首先,我不认为短路能够明智地应用到XOR:无论第一个操作数的值,要检查的第二个需求

Firstly, I don't think shortcircuiting can sensibly apply to XOR: whatever the value of the first operand, the second needs to be examined.

其次,和,和放大器;&放大器,或和||使用在所有情况下短路; 道和符号版本之间的唯一区别是precedence。我相信,是present提供相同的功能,Perl有在线条状

Secondly, and, &&, or and || use shortcircuiting in all cases; the only difference between the "word" and "symbol" versions is precedence. I believe that and and or are present to provide the same function as perl has in lines like

process_without_error or die

我觉得没有一个 XOR 命名函数的原因可能是有在这种情况下,低precedence运营商是没有意义的,它已经是一个混乱的局势不够!

I think the reason for not having a xor named 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!

这篇关于关键字为独占或红宝石?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆