我正在尝试“99 瓶”计划。我试图简化它,但我得到“字符串不能被强制转换为 Fixnum”:
num_at_start = 99
num_now = num_at_start
bobo = " bottles of beer on the wall"
bob = " bottles of beer!"
while num_now > 2
puts num_now.to_s + bobo.to_s
puts num_now.to_s + bob.to_s
puts num_at_start.to_i - 1 + bobo.to_s
gets
end