我有一个哨兵控制的循环似乎没有接受任何输入:
response = " "
until response == "x" do
puts"
Xargonia
=========
(N)ew
(L)oad
(O)ptions
(Q)uit"
reponse = gets
puts response
当它尝试输出用户输入的内容时,只需要用于初始化的内容。
答案 0 :(得分:1)
除了语法错误之外,您还要将gets
的值分配给reponse
而不是response
。此外,您还希望通过链接gets
来删除String::chomp
中的换行符:
response = " "
until response == "x" do
puts " # add space between gets and double-quote
Xargonia
=========
(N)ew
(L)oad
(O)ptions
(Q)uit"
response = gets.chomp # rename reponse to response; chain .chomp
puts response
end # add missing end