> 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
> 
> 
> 
> Thanks
> PR


Try:

"hi " + @fname.to_s + ", " + @lname.to_s"

Then nil would be an empty string.

--
Tomasz 'blazeroot'