From: Robert Klemme Date: 2005-08-07T22:51:08+09:00 Subject: Re: Adding yet another Array.new form Nikolai Weibull wrote: > How about adding a fifth way of constructing new arrays?: > > Array.new{|array| block } > > Here, array is the newly created array, and the block will initialize > it as it sees fit, e.g, > > ary = Array.new{ |ary| 5.times{ |i| ary << i } }, > > which is a stupid way of doing it (Array.new(5){ |i| i } would do), > but it shows the idea. I often find myself writing methods that fit > the following template: > > def a > ary = [] > .. construct ary by adding elements to it ... > ary > end But *what* are the initializations you cannot do nicely ATM? Note, that there are also forms that make use of map and inject that can be quite concise... Kind regards robert