我正在學習Ruby,並面臨一些問題。我試圖比較表達式的總和與整數,並得到這個返回:「比較字符串與2000失敗」。非常感謝!如何比較表達式的總數與Ruby中的整數?
puts "Hello! Please type here your birthday date."
puts "Day"
day = gets.chomp
day.capitalize!
puts "Month"
month = gets.chomp
month.capitalize!
puts "Year"
year = gets.chomp
year.capitalize!
if month + day + year > 2000
puts "Sum of all the numbers from your birthday date is more than 2000"
else month + day + year < 2000
puts "Sum of all the numbers from your birthday date is less than 2000"
end
大寫的整數?爲什麼? –
@YevgeniyAnfilofyev:他們變大:) –
當然,再投資;) –