我正在尝试设置一个条件来检查输入句子是否大写。
puts "Whats your name?"
name = gets.chomp
while (input == "I love you aunty, I have to go now") == false do
puts "Say something"
input = gets.chomp.to_s
if (input == input.capitalize)
puts "SHOW SOME RESPECT"
elsif input == input.upcase
puts "SPEAK UP"
end
end
输入单个字符串时,会显示SHOW SOME RESPECT
,但输入多个字符串时。它返回say something
。