【问题标题】:Ruby logical operators [duplicate]Ruby逻辑运算符[重复]
【发布时间】:2011-03-14 15:03:54
【问题描述】:

可能重复:
Is there any wisdom behind “and”, “or” operators in Ruby ?

以下逻辑运算符对之间有什么区别(如果有)?

  1. && 与和
  2. ||与或

【问题讨论】:

标签: ruby logical-operators


【解决方案1】:

“word”版本的优先级低于“symbol”版本。事实上,它们的优先级甚至低于赋值。

【讨论】:

  • 这可以解释为什么 @user = User.find_by_id('test2@example.com') or User.find_by_email('test2@example.com')@user 设置为 nil,即使记录存在。
猜你喜欢
  • 2019-04-21
  • 2020-10-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-09-06
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多