我在 Ruby 中有一段代码,如下所示:
def check
if a == b || c == b
# execute some code
# b = the same variable
end
end
可以这样写吗
def check
if a || c == b
# this doesn't do the trick
end
if (a || c) == b
# this also doesn't do the magic as I thought it would
end
end
或者以我不需要输入b
两次的方式。这是出于懒惰,我想知道。