2013-02-05 28 views
-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

你是什麼意思'錯'什麼是或不工作?你能給我們一些錯誤嗎? – BlackHatSamurai

+0

不知道,命令提示符關閉太快,我看不到。 –

回答

2

你可能希望將這些字符串轉換成整數:

first_digit = gets.chomp.to_i 

而且,你在這裏忘了下劃線:

answer = second_digit + first digit 
          ^right here 
+0

有趣的是,這樣的小東西搞砸了你的項目。謝了哥們!這是我的第一個沒有教程的項目! –