From: Ant Walliams Date: 2010-05-29T04:17:56+09:00 Subject: Re: A complete beginners question Rob Biedenharn wrote: > On May 28, 2010, at 2:59 PM, Ant Walliams wrote: >> making your changes. Any ideas? >> >> Thanks >> Ant > > the problem is with number+=1 > > number is a string because gets.chomp is a string > > number+=1 is syntactic sugar for > number = number + 1 > > And the expression number + 1 is trying to add 1 (a Fixnum) to a string > > Try changing: > > number = gets.chomp.to_i > > to convert the string into an integer (which if small enough will be > held in an instance of Fixnum). > > Then, you'll have the opposite problem with the last line unless you > incorporate Reid's suggestion. > > -Rob > > Rob Biedenharn http://agileconsultingllc.com > Rob@AgileConsultingLLC.com Thank you very much, that worked. And thanks for the explanation of how it works as well, that really helps. Thanks Ant -- Posted via http://www.ruby-forum.com/.