From: Ehsanul Hoque Date: 2009-09-19T14:58:24+09:00 Subject: Re: How to derive from DateTime? --_5b8943de-2d95-4884-8a01-fdbd825d996a_ Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable >=20 > Thank you for that code it looks like a good solution and will use > it. However=2C I am left wondering why this anomaly with the > constructors in DateTime=2C does that not violate OO practices. How can > you not be able to inherit from a Class X and redefine it. >=20 > Thanks a lot... >=20 Actually=2C there's no anomaly really=2C as far as I know. There's some bug= in the code. I have no idea where=2C your code seems fine to me=2C and it = could just be because of the way the DateTime class was implemented. But yo= u can in fact redefined constructors=2C and it works fine. Try this for exa= mple (just an adaptation of your code): class Foo def initialize(x) @x =3D x @message =3D "message from foo" end attr_accessor :message=2C :x end class Bar < Foo class << self alias :old_new :new def new(x) obj =3D old_new obj.send :initialize obj end end =20 def initialize @message =3D "message from bar" end =20 attr_accessor :message end f =3D Foo.new(0) f.message #=3D> "message from foo" f.x #=3D> 0 b =3D Bar.new(0) b.message #=3D> "message from bar" b.x #=3D> nil (I actually don't understand why this is=2C someone= else might be able to explain) =0A= _________________________________________________________________=0A= Bing=99 brings you maps=2C menus=2C and reviews organized in one place. = Try it now.=0A= http://www.bing.com/search?q=3Drestaurants&form=3DMLOGEN&publ=3DWLHMTAG&cre= a=3DTEXT_MLOGEN_Core_tagline_local_1x1= --_5b8943de-2d95-4884-8a01-fdbd825d996a_--