Or

num = gets.chomp
puts 'well ' + num.succ + ' + var1 is better'


Mike Peltzer wrote:
> Hi all, I am very to new to ruby and am having trouble writing a very
> simple program: basically i just want to ask for an integer then return
> the integer +1
> here is my code:
> ---------------------------------------------------
> puts 'what\'s your favorite number?'
> var1 = 1
> num = gets.chomp
> puts 'well ' + num.to_i + ' + var1 is better'
> 
> ------------------------
> 
> when I run it, this is the error i get:
> ---------------------------------------
> what's your favorite number?
> 3
> ri20min.rb:5:in `+': can't convert Fixnum into String (TypeError)
>   from ri20min.rb:5:in `<main>'
> ---------------------------------------
> I realize this is laughable, but I am struggling with the concept, any
> help is greatly appreciated.

-- 
Posted via http://www.ruby-forum.com/.