-2

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

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
4

1 回答 1

2

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

first_digit = gets.chomp.to_i

另外,您在这里忘记了下划线:

answer = second_digit + first digit
                             ^ right here
于 2013-02-05T00:53:57.963 回答