Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否有类似的红宝石成语:
a==b || a==c
我认为以下应该有效,但它没有
a == b||c
有时我会用Array#include?一长串值来检查是否相等。
Array#include?
[1,2,3].include? 2 # true [1,2,3].include? 4 # false
但是对于 2 个值,通常a == 1 || a == 2更容易和更简单。
a == 1 || a == 2
也被广泛使用:
[b, c].include?(a)
a==b || a==c是正确的方法。
Ruby 将不支持a == b||c.