From: David Alan Black Date: 2001-02-24T03:15:11+09:00 Subject: [ruby-talk:11397] Re: Time without seconds (updated/fixed) On Sat, 24 Feb 2001, W. Kent Starr wrote: > On Friday 23 February 2001 10:32, David Alan Black wrote: > > Here's a followup question, based on playing around with this: > > Why do the two ways of doing this (which I've stashed into > > MyTime.floor) result in objects of different types? > > > > class MyTime < Time > > def MyTime.floor > > > > # Way 1 > > t = Time.new > > mt = MyTime.at t - t.sec > > > > # Way 2 > > tt = MyTime.at (tm = Time.new) - tm.sec > > > > [mt,tt].each do |ti| > > puts "#{ti} is of type #{ti.type}" > > end > > end > > end > > > > MyTime.floor > > > > Output: > > Fri Feb 23 10:31:00 EST 2001 is of type MyTime > > Fri Feb 23 10:31:00 EST 2001 is of type Time > > > > > FWIW > > Time.type #-> Class > class MyTime < Time > end > MyTime.type #-> Class > a = Time.new > b = MyTime.new > a.type #-> Time > b.type #-> MyTime > > It appears that a class is of type Class and instances of that class are of > type #{Name_Of_That_Class} > > Interesting (and useful) behavior :-) Indispensable, even :-) But I don't see the connection with my question. But see earlier answers from Dave T. and Guy D. (Is there *anyone* on this list without at least one name twin? Slight exaggeration... but still!) David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav