下面的代碼輸出333代替9.如何將字符串加在一起
如何更改它以打印總和計算而不是字符連接?
puts 'What is your first name?'
first = gets.chomp
puts 'What is your middle name?'
middle = gets.chomp
puts 'What is your last name?'
last = gets.chomp
var1 = first.length.to_s
var2 = middle.length.to_s
var3 = last.length.to_s
puts 'Did you know there are ' + var1 + var2 + var3 + ' characters in your name, ' + first + ' ' + middle + ' ' + last
歡迎來到Stack Overflow。請閱讀「[問]」,包括鏈接的頁面。我們不關心你的經驗水平,只關心你的嘗試,展示你的嘗試,並且你問了一個深思熟慮的問題。 –