From: Dave Thomas Date: 2002-01-25T03:55:26+09:00 Subject: Re: Serious Array Bug in Ruby 1.6.6? matz@ruby-lang.org (Yukihiro Matsumoto) writes: > Hi, > > In message "Re: Serious Array Bug in Ruby 1.6.6?" > on 02/01/25, nobu.nokada@softhome.net writes: > > |Hmmm, I'll suggest to change Array.new to take a block when > |no default value given. That is: > | > | a = Array.new(2) {|i| Hash.new} # i is 0, 1... > > Instead, how about Array#fetch to take block for the default value? > (I already did in my local copy.) Why not make the Array constructor consistent with Hash? The semantic seems the same. Array.new {|aref,i| ...} then calling a[99] would invoke the block, passing in the array and '99'. Whenever the block returned would be the value in the array. Isn't this the way Hash.new works? Dave