puts "Whats your favourite number?"
num = gets.to_i
puts "This is better: #{num+1}"


woodyee schrieb:
> Hi! I'm stuck on Chapter 5, 5.4:
> 
> "Write a program which asks for a person's favorite number. Have your
> program add one to the number, then suggest the result as a bigger and
> better favorite number. (Do be tactful about it, though.)".
> 
> Any ideas? I'm getting "can't convert fixnum into string" errors.
> Here's one of the many things I've tried, er, failed:
> 
> puts 'What is your favorite number ?'
> num = gets.chomp
> better = 'num'.to_i + 1
> puts 'This is better: ' + better + '.'
> 
> 3rd line's getting me. Can't figure out how to add 1 to the response.
> Hopefully, I'll figure this out but any tips are welcomed. Thanks!
>