On 19/12/11 14:52, Fellipe de Paula wrote:
> I'm starting to learn Ruby using the Learn to Program book by Chris
> Pine.
>
> On a mini assignment I need to:
>
> "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.) "
>
> Here's what I have so far...
>
> 1 full_name = first_name + ' ' + middle_name + ' ' + last_name
> 2 puts full_name + ', ' + 'What\'s your favorite number???'
> 3 favorite_number = gets.chomp
> 4 new_number = favorite_number.to_i + 1
> 5 puts 'hmmm... What about ' + new_number + '? ' + 'It\'s bigger and
> better than yours :)'
>
> The program runs smoothly until line 4 than it returns the following
> error:
>
> :in `+': can't convert Fixnum into String (TypeError)
>
> Could you please point my mistake?

You might want to convert "new_number" from an integer into a string 
before you add it to the string. :) Try adding ".to_s" after "new_number".

>
> Thanks,
> Fellipe
>