A
Ara.T.Howard
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
===============================================================================
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
===============================================================================