Need Help with a Very Simple Program
I've been working my way through 'Learning to Program,' by Chris Pine, to begin to understand both Ruby and the general concepts of programming. Anyway, the little program I've written accomplishes a simple task: it asks for your favorite number, adds one to it, then returns it to you. Here it is:
For some reason, I get an error (in terminal) that says :'String can't be coerced into Fixnum (TypeError).' Why can't this variable--which contains a numeric string--be converted into an integer?
puts 'Hey there, I\'m Uno.'
puts 'What\'s your favorite number?'
number = gets.chomp
better = number.to_i + 1
puts better + '...That\'s better.'