From: Luis Lavena Date: 2010-09-29T13:00:14+09:00 Subject: Re: Error - "`+': can't convert nil into String" On Sep 29, 12:03 am, Paul Roche wrote: > Why does the code below give me this error? What can I do to fix it? > > /people3.rb:4:in `+': can't convert nil into String (TypeError) > om C:/Ruby192/people3.rb:4:in `to_s' > > class Person > attr_accessor :fname, :lname, :age > def to_s > "hi " + @fname + ", " + @lname > end > > end > Either @fname or @lname are nil You can't concatenate nil to an string. -- Luis Lavena