【问题标题】:ruby conjunction and union operators [duplicate]红宝石连接和联合运算符[重复]
【发布时间】:2013-08-14 03:29:58
【问题描述】:

所以我刚刚(偶然)发现 Ruby 允许以下语法:

if foo and bar

if foo or bar.

这与(如果有的话?)有何不同

if foo && bar

if foo || bar

运营商是否不同?怎么样?

【问题讨论】:

    标签: ruby login


    【解决方案1】:

    运营商是否不同?

    是的,它们按照运算符的优先级。

    怎么做?

    有关详细信息,请参阅Difference between “and” and && in Ruby?Difference between “or” and || in Ruby?

    【讨论】:

    • andor 是短路的,它们只是优先级较低
    • @DylanMarkow 抱歉,我已更正.. 谢谢..
    猜你喜欢
    • 2011-08-12
    • 1970-01-01
    • 2011-04-28
    • 1970-01-01
    • 2011-02-28
    • 2011-08-02
    • 1970-01-01
    • 2010-09-09
    • 2014-08-06
    相关资源
    最近更新 更多