Hi --

On Wed, 14 Jul 2004, Brian Schroeder wrote:

> 
> > Please share your quickies!
> > 
> > 
> 
> A complement to Array each_with_index that I find myself using quite often
> when juggling with Arrays. Makes the code more legible.
> 
> class Array
>   def collect_with_index
>     r = Array.new(length)
>     each_with_index do | o, i | r[i] = yield(o,i) end r
>   end
> end

This is a perennial favorite :-)  I still pull in my home-made
version fairly often. 


David

-- 
David A. Black
dblack / wobblini.net