M
Max Norman
I'm almost an absolute novice in Ruby; it is my first language and I
just began learning the basics yesterday, using Chris Pine's 'Learning
to Program.'
The trouble I'm having is simple, but nonetheless I would appreciate an
explanation. 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:
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.'
I'm receiving this error: String can't be coerced into Fixnum
(TypeError).' Why can't this variable--which contains a numeric
string--be converted into an integer?
just began learning the basics yesterday, using Chris Pine's 'Learning
to Program.'
The trouble I'm having is simple, but nonetheless I would appreciate an
explanation. 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:
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.'
I'm receiving this error: String can't be coerced into Fixnum
(TypeError).' Why can't this variable--which contains a numeric
string--be converted into an integer?