I found some issues with the above proposed solutions that I wanted to 
ask about:
>>
>> class NameIt
>>  def initialize(name)
>>    @name = name
>>  end
>>  def to_s
>>    puts "My name is: #{@name}"
>>  end
> 
>   def to_s
>     "My name is: " << name
>     # no puts
>   end
> 
>> end

Clarifications/comments:

it appears that << name needs to be changed to << @name for it to work. 
I assume this is because the scope of "name" is only known in the 
initialize method and not the to_s method? I understand the scope of the 
instance variable to be visible throughout the class. Is this the 
reason?

Another question:

I entered this in:
class NameIt
  def initialize(name)
    @name = name
  end
  def to_s
    puts "My name is: " << @name
  end
end
names = %w( tom sally doug john)
nameits = names.map {|name| NameIt.new(name)}
nameits.each{|n| puts n.to_s}

and it returned this:
>
My name is: tom
nil
My name is: sally
nil
My name is: doug
nil
My name is: john
nil
>Exit code: 0

Where did the nil come from?

Thanks! Jason

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