From: Nat Pryce Date: 2002-11-22T19:55:08+09:00 Subject: Re: [FAQ] Multiple constructors? On Fri, 2002-11-22 at 10:17, Martin DeMello wrote: > Nat Pryce wrote: > > If you want to have different constructors for different argument types, > > define different constructors on your class. Your code will then be > > both more flexible and more readable. E.g. If you had a class that > > could be created with either a String and a Regexp you would define > > constructors new_from_string(a_string) and new_from_regexp(a_regexp). > > This won't let me do something like > > my_objs = input_objs.map {|i| MyClass.new(i)} That's true but how often does one put arbitrary objects into a collection and then use them to create something? And if you do, you can easily put different types of objects into different collections. Cheers, Nat. -- Nat Pryce B13media