From: aero6dof@... (Alan Chen) Date: 2004-06-02T08:33:38+09:00 Subject: Re: Object#collect was Re: [RCR] Numeric#of gabriele renzi wrote in message news:<1aulb0pj5pk1b5hup1otnt70plqn4dnifh@4ax.com>... > il Tue, 25 May 2004 15:37:04 -0600, "Ara.T.Howard" > ha scritto:: > > > > > >how about this? > > > > > >Object#collect > > > > > > them = collect(3){ Array.new } > > > > should'nt this be Kernel::collect? > Anyway, I'd prefer to see Object#* :) > them = Array.new * 3 # actually dup/clone I had one suggestion which I think was lost in the recent gateway debug process... I'll repeat it again below - hopefully it wasn't a simply bad idea :) To me, creating multiple instances of initialized objects feels like it belongs more with the new call, rather than Integer. Perhaps we could add a "multiple instance" new? Here is one implementation. def Object.newx( nx, *args) instances = [] if( block_given? ) nx.times { instances.push yield(self.new(*args)) } else nx.times { instances.push self.new(*args) } end instances end a,b,c = Array.newx(3) I'm not sure what should be done when the new also expects a block.