这段代码有什么问题?如果你输入里程这个词,它应该停止。 [英] What is wrong with this code? It should stop if you typed the word miley.
本文介绍了这段代码有什么问题?如果你输入里程这个词,它应该停止。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
puts("What do you call a girl whose tongue is out all the time!")
what = gets
while what != 'miley'
puts("Try again! Think and twerk!")
what = gets
end
puts(what.chomp+ ". Wow, you have no life".chomp)
推荐答案
puts("What do you call a girl whose tongue is out all the time!")
what = gets.chomp
while what != "miley"
puts("Try again! Think and twerk!")
what = gets.chomp
end
puts(what.chomp+ ". Wow, you have no life".chomp)
输入结尾有一个新行.chink方法将摆脱它。
如有疑问,请使用 String#dump [ ^ ]以确保获得您认为的结果。
The input had a new line at the end. The chomp method will get rid of it.
When in doubt, use String#dump[^] to make sure you are getting what you think you are getting.
这篇关于这段代码有什么问题?如果你输入里程这个词,它应该停止。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文