Hi -- On Tue, 11 Dec 2001, Harry Ohlsen wrote: > In article <Pine.LNX.4.30.0112100941570.3130-100000 / candle.superlink.net>, > "David Alan Black" <dblack / candle.superlink.net> wrote: > > > I can understand that for Array... but the thing that I found > > un-POLS-like is: > > > > class Thing < Array > > def to_s > > # ... > > end > > end > > > > and then Thing objects still get puts'd according to the rules of how > > Array is handled. > > Unless I've misunderstood, I think the issue is that puts isn't a > method of Array (nor of Thing). In general (?), though, puts will consult an object's to_s method, so defining that method governs the result of puts'ing that object: class Thing < Hash alias :oldto_s :to_s def to_s "I look like this: " + oldto_s.split("").join("-") end end t = Thing[1,2,3,4] puts t # => I look like this: 1-2-3-4 class Whatever def to_s "I am a Whatever." end end puts Whatever.new # => I am a Whatever. So the un-POLS reaction is to the fact that subclasses of Array (and, upon reflection, Array itself, I have to admit) don't act this way too. David -- David Alan Black home: dblack / candle.superlink.net work: blackdav / shu.edu Web: http://pirate.shu.edu/~blackdav