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”)
对其进行测试。谢谢,我将尝试一下