From: David Alan Black Date: 2002-06-22T03:06:59+09:00 Subject: Re: What rational for failure of ("" << nil) and of ("" << :Foo) ? Hello -- On Thu, 20 Jun 2002, Jean-Hugues ROBERT wrote: > Hello, > > What is the rational for failure of "" << nil and of "" << :Foo ? > > Apparently <<() (and +()) uses to_str() only, never to_s(). > > However this works: "#{nil}#{:Foo}" > > I may do this to define to_str(): > class NilClass > def to_str() to_s() end > end > class Symbol > def to_str() to_s() end > end > and then ("" << nil << :Foo) works. > > ... But I wonder if that could break things in some other cases? See whether , which was my shot last year at explaining the #to_str/#to_s relation (both what and why), is helpful. (It isn't the last word in this area, but it's pretty much what I'd still say, so I'll refer to it rather than quote it at length :-) David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav