On Tue, 1 Jun 2004, Alan Chen wrote:

> gabriele renzi <surrender_it / remove.yahoo.it> wrote in message news:<1aulb0pj5pk1b5hup1otnt70plqn4dnifh / 4ax.com>...
>> il Tue, 25 May 2004 15:37:04 -0600, "Ara.T.Howard" <ahoward / noaa.gov>
>> 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.

i see your point, but my original idea was not only for constructing objects,
but for doing 'something' n times:

admittedly lame example:

   results = 16.of{|n| db.execute(build_query(n)) }

-a
--
===============================================================================
| EMAIL   :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE   :: 303.497.6469
| A flower falls, even though we love it; and a weed grows, even though we do
| not love it. --Dogen
===============================================================================