我目前的代码是这样的:
print "Feed me input."
def get_input
input_value=gets.chomp
if !input_value
print "you didn't type anything"
else
input_value.downcase!
if input_value.include? "s"
input_value.gsub!(/s/,"th")
else
print "You entered a string but it had no 's' letters."
end
end
return input_value
end
get_input()
if !get_input
get_input
else
puts "#{get_input}"
end
我不确定为什么它不起作用。当我运行它时,我会提示输入,然后当我在输入 none 后按 enter 时,我得到“你输入了一个字符串,但它没有's'字母”,而不是我想要的“你没有输入任何东西”。