From: Wayne Blair Date: 2001-05-15T11:10:04+09:00 Subject: [ruby-talk:15133] Re: initialize overload I read a few posts that mentioned method overloading might be coming in 1.7 or a future release. Not sure if that's accurate, or if it would extend to constructor overloading. I would certainly like to see it, too. Wayne "Jim Freeze" wrote in message news:Pine.BSF.4.32.0105141755450.91657-100000@www.stelesys.com... > Ok, the synapsis aren't firing so well today. > How do I overload a constructor to get the effect: > > m1 = Myclass.new(some_object) > m2 = Myclass.new("text", "number") > > I cannot do: > > class Myclass > def initialize(o) > # use o > end > def initiaize(type, level) > # use type and level > end > end > > > Do I have to do something like: > > class Myclass > def initialize(a, b=nil) > if Type == a.type > #do this > else > #do that > end > end > end > > Thanks > > ========================================================= > Jim Freeze > jim@freeze.org > --------------------------------------------------------- > No comment at this time. > http://www.freeze.org > ========================================================= >