----- Original Message ----- From: Dave Thomas <Dave / PragmaticProgrammer.com> To: ruby-talk ML <ruby-talk / ruby-lang.org> Sent: Sunday, February 18, 2001 3:02 PM Subject: [ruby-talk:11067] Re: to_s and << > "Hal E. Fulton" <hal9000 / hypermetrics.com> writes: > > > > And yet, this can't be the whole story, since the TypeErrors do > > > happen. Further detective work (and/or clarification by those ahead > > > of me in the process :-) required.... > > > > I've wondered about this too... Dave, could this be considered a bug > > in The Book? > > Perhaps, but I don't think so. to_str is not the same as to_s. to_str > only works on things that pretend to be Strings in the first place > (String and Exception are two basic classes), so you'll get a type > error if you use anything else. > Well, if you look at the << method, it just says it takes "anObject"... I don't recall seeing anything about to_str (or to_s) anywhere... I thought at first that I could use an arbitrary object there... but I guess you have to define to_str if you want to do that? Hal