On Wed, 1 Feb 2006, Yukihiro Matsumoto wrote:

> Hi,
>
> On 2/1/06, ara.t.howard / noaa.gov <ara.t.howard / noaa.gov> wrote:
>
>> i threw this out before.  thought i'd try again:
>>
>>    harp:~ > irb
>>    irb(main):001:0> class Numeric; def of(&b) Array::new(self).map(&b) end; end
>>    => nil
>>
>>    irb(main):002:0> 42.of{ String::new }
>>    => ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]
>
> Using my not-yet-committed 1.9, you can type
>
>  42.times.collect{String::new}
>
> to get the same result.

great!  i'm still partial to the shorter version since

   42.times.collect{String::new}

isn't that much shorter/prettier than my current idiom of

   Array::new(42).map{String::new}

but it's the capability that's needed so this is good news.

kind regards.

-a

-- 
happiness is not something ready-made.  it comes from your own actions.
- h.h. the 14th dali lama