Eric Hodel
10/11/2007 7:18:00 AM
On Oct 10, 2007, at 19:58 , 7stud -- wrote:
> Eric Hodel wrote:
>> On Oct 10, 2007, at 15:31 , Martin DeMello wrote:
>>
>>> => foo
>> it calls #to_s.
>
> class Dog
> def to_s
> print "dog"
> end
> end
>
> d = Dog.new
>
> print d
> puts
>
> puts d
>
> --output:--
> dog#<Dog:0x25634>
> dog#<Dog:0x25634>
In IO#write, if #to_s returns nil, rb_any_to_s() gets called, which
returns "#<#{self.class}:0x#{object_id.to_s 16}>", which gets printed
instead of your broken #to_s.
--
Poor workers blame their tools. Good workers build better tools. The
best workers get their tools to do the work for them. -- Syndicate Wars