我的代码行有什么问题?

时间:2013-02-05 00:52:17

标签: ruby

这里有什么问题?我不知道?

print "Type the first digit, hit enter."
first_digit = gets.chomp

print "Now type the second digit you wish to add."
second_digit = gets.chomp

answer = second_digit + first digit

print "Here is your answer:#{answer}"


sleep 5

1 个答案:

答案 0 :(得分:2)

您可能希望将这些字符串转换为整数:

first_digit = gets.chomp.to_i

另外,你在这里忘了一个下划线:

answer = second_digit + first digit
                             ^ right here