-5
我在做第11個練習瞭解Ruby的難法。我一定要得到這樣的:通過寫這Gets.chomp不能正常工作
How old are you? 35
How tall are you? 6'2"
How much do you weigh? 180lbs
So, you're 35 old, 6'2" tall and 180lbs heavy.
:
print "How old are you? "
age = gets.chomp()
print "How tall are you? "
height = gets.chomp()
print "How much do you weigh? "
weight = gets.chomp()
puts "So, you're #{age} old, #{height} tall and #{weight} heavy."
,但我得到這個:
How old are you?
How tall are you?
How much do you weigh?
So, you're old, tall and heavy.
這意味着,gets.chomp
不工作,我不明白任何東西。
方法'gets.chomp()'在哪裏?這似乎要麼沒有返回,要麼可能是其他問題......? – gravity
@gravity'Kernel#gets'和'String#chomp'是Ruby核心方法。 –
@MladenJablanović這是我的觀點:) – gravity