From: Phrogz Date: 2007-10-11T12:35:03+09:00 Subject: Re: what does print call internally? On Oct 10, 9:25 pm, 7stud -- wrote: > I don't understand the output of my first example: print returns nil, so > print 'dog' should return nil, which means to_s returns nil, and so > print d should be equivalent to print nil. If to_s returns something other than a string, Ruby shakes a naughty finger at you and ignores you, and falls back on the result of Kernel#inspect instead. irb(main):001:0> class Foo; def to_s; 42; end; end => nil irb(main):002:0> puts Foo.new # => nil irb(main):003:0> class Foo; def to_s; "42"; end; end => nil irb(main):004:0> puts Foo.new 42