"Learn ruby the hard way" 缺少练习 14 的输出

"Learn ruby the hard way" missing puts output on exercise 14

我目前正在和一个朋友一起做练习 14,这是一些非常简单的字符串插值和用户输入抓取。我的代码如下所示:

user_name = ARGV.first                                                          
prompt = '> '

puts "Hi #{user_name}."
puts "I'd like to ask you a few questions."
puts "Do you like me #{user_name}? ", prompt
likes = $stdin.gets.chomp

puts = "Where do you live #{user_name}? ", prompt
lives = $stdin.gets.chomp

puts "What kind of computer do you have? ", prompt
computer = $stdin.gets.chomp

puts """
Alright, so you said #{likes} about liking me.
You live in #{lives}. Not sure where that is.
And you have a #{computer} computer. Nice.
"""

应该很简单,但我发现在 likes= 行之后,提示输入 "where do you live" 的下一行没有显示在屏幕上,但是 lives= 被提示。也就是输入"likes"后立即跳转到"lines"提示符,而没有给我显示之前输出的提示符!从 computer= 开始的下一个提示按预期工作。

我正在使用 ruby 2.1.2,但在 2.2.3 上出现了相同的行为,并且在线 REPL here

为什么会这样?

您在第 8 行的 puts 之后有一个 =。删除它应该可以解决问题。