I like it. I particularly like the added detail of yielding the index into the creation, in case you need that info. Kudos, and thanks for the snippet! Alex McHale On Tue, 25 May 2004 02:58:44 +0900, Ara.T.Howard <ara.t.howard / noaa.gov> wrote: > > > i end up doing this sort of thing alot: > > avg, max, min = {}, {}, {} > > stack_a, stack_b = [], [] > > and was thinking about a general syntax for 'n of these' or 'n of the result > of this block'... does this read alright? > > ~ > cat of.rb > class Numeric > def of > ret = [] > times{|i| ret << yield(i)} > ret > end > end > > them = 3.of{ Array.new } > p them # => [[],[],[]] > > -a > -- > =============================================================================== > | EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov > | PHONE :: 303.497.6469 > | ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328 > | URL :: http://www.ngdc.noaa.gov/stp/ > | "640K ought to be enough for anybody." - Bill Gates, 1981 > =============================================================================== > >