>Every object will respond to to_s, and to_s will always give you
>*something*.  But sometimes you might want a given class to have a
>non-canonical way of showing itself as a string.  In such a case, you
>can define a to_str method, such that your objects have their own idea
>of how to represent themselves as strings.

I would have thought that, generally speaking, the "canonical" form is
going to be fairly uninformative.  Hence, anyone who wants to have a
more "meaningful" string representation for their class would want it
to be used whenever a string is needed.  Hence, they'd want it to be
what "to_s" generates.

>A little test/demo:
>
>   class Pretender
>
>     attr_reader :to_str
>
>     def initialize(s)
>       @to_str = "I am a Pretender object initialized with #{s}."
>     end
>
>   end

So, here, for example, I would have thought you'd want to define
"to_s" rather than "to_str".

I just can't see why one would decide that there's a better
representation and then only organise that Ruby produces it in limited
circumstances, rather than every time it needs a string.

Can someone maybe give us a concrete example, either from the class
libraries or their own code?