From: Brian Schroeder Date: 2004-07-14T06:27:21+09:00 Subject: Re: Ruby quickies and useful idioms > 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 greetings, Brian -- Brian Schr�der http://www.brian-schroeder.de/