From: Richard Kilmer Date: 2003-09-12T03:56:11+09:00 Subject: Re: ANN: MetaTags 1.0 On Thursday, September 11, 2003, at 01:31 AM, Martin DeMello wrote: > Dave Thomas wrote: >> >> Or perhaps even using the '>>' operator (as in 'becomes' or 'inject >> into') >> >> c = "one hump or two" >> Caml > > Nice! And perhaps the other way around too - I notice that Class#<< is > undefined. > > c = Caml << "one hump or two" (read 'from') > > martin > Oh my...improving on perfection! You could make this type-selectable: class Date def self.__String(string) puts "String factory" Date.new end def self.__Fixnum(millis) puts "Fixnum factory" Date.new end end class Class def <<(object) sym = "__#{object.class}".intern return send(sym, object) if respond_to?(sym) return nil end end d = Date << "String" d = Date << 1234543 The generic factory pattern!