From: Merrie Date: 2007-04-04T05:15:42+09:00 Subject: Re: Question - Numbers & Variables James, thank you very much for the help! Merrie S ----- Original Message ----- From: "James Edward Gray II" To: "ruby-talk ML" Sent: Tuesday, April 03, 2007 4:11 PM Subject: Re: Question - Numbers & Variables > On Apr 3, 2007, at 2:51 PM, Merrie wrote: > >> What I would like to see is: What is your favorite number? 14 Well >> this 15 (adding 1) might be better. The error is relating to to_i >> but Im not sure where to place it on the num or the +1? > > There are two errors in the script. You need to help Ruby know when > to convert the objects you are working with... > >> puts 'What is your favorite number?' >> num = gets.chomp >> num=num +1 > > num = num.to_i + 1 # we have a String, but want an Integer > >> puts 'Well this ' + num + ' might be better.' > > # now we need to go back to a String so we can concatenate > puts 'Well this ' + num.to_s + ' might be better.' > > Does that help? > > James Edward Gray II >