From: "Ara.T.Howard" Date: 2005-10-15T12:47:45+09:00 Subject: Re: Factory function like Array() for your own classes On Sat, 15 Oct 2005, Sean O'Halpin wrote: > On 10/15/05, Dave Burt wrote: > > [snip] > >> Why not just use ..new? Why does new need an alias? > > It doesn't ~need~ an alias. It's just quite handy sometimes when you > are creating lots of nested objects to avoid having to type new all > the time. For example, in a report DSL, you could use something like: > > r = Report( > :header => Header( :title => "My report" ), > :body => Body( :rows => Query(:sql => "SELECT * FROM Supplier")) > ) > > instead of > > r = Report.new( > :header => Header.new( :title => "My report" ), > :body => Body.new( :rows => Query.new(:sql => "SELECT * FROM Supplier")) > ) > > Not a big gain, but in my opinion, the .new in the second example is > just adding noise. It's a matter of taste I guess. i'm with you - i do it all the time in my own code ;-) -a -- =============================================================================== | email :: ara [dot] t [dot] howard [at] noaa [dot] gov | phone :: 303.497.6469 | anything that contradicts experience and logic should be abandoned. | -- h.h. the 14th dalai lama ===============================================================================