Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby 我怎样才能得到两个相同的单词的小写和大写?_Ruby - Fatal编程技术网

Ruby 我怎样才能得到两个相同的单词的小写和大写?

Ruby 我怎样才能得到两个相同的单词的小写和大写?,ruby,Ruby,这是一个例子: Puts "#{input}" If input == "Hello" || "hello". <== What to be able to enter same word but lower case and uppercase Puts "nice to meet you" Elsif input == "Bonjour" || "bonjour" Puts "that's french" Else Puts "user input " End put“#{

这是一个例子:

Puts "#{input}"
If input == "Hello" || "hello".      <== What to be able to enter same word but lower case and uppercase
Puts "nice to meet you"
Elsif input == "Bonjour" || "bonjour"
Puts "that's french"
Else
Puts "user input "
End
put“#{input}”
如果输入==“你好”| |“你好” 用于将输入更改为小写,然后只需与小写单词进行比较

def respond(input)
  case input.downcase
  when "hello" then puts "hello"
  when "bonjour" then puts "that\'s french"
  else puts "user input"
  end
end

可能重复的是,这样我就可以输入hello小写和大写是的,在定义此方法后,您可以通过调用
respond(“hello”)
respond(“hello”)
对其进行测试。谢谢,我将尝试一下