Ruby' OR'用于字符串文字

时间:2012-11-28 05:28:10

标签: ruby string compare

我如何重新考虑这样的事情?

response = "yes"

if response == "yes" or response == "y"
  puts "Do Something"
end

2 个答案:

答案 0 :(得分:4)

if %w(yes y).include?(response)

答案 1 :(得分:-1)

你可以像以下一样使用,我希望它可以帮到你

<强>示例

如果@response =='R'|| @response =='r'

如果您输入 OR ,则会显示错误

相关问题