From: nobu.nokada@... Date: 2002-01-25T02:22:52+09:00 Subject: Re: Serious Array Bug in Ruby 1.6.6? Hi, At Fri, 25 Jan 2002 01:56:24 +0900, William Djaja Tjokroaminata wrote: > At least, probably the book should not give that example. In the more > general terms, probably Ruby should change the behavior of Array.new (n, > Hash.new) as opposite to, say, Array.new (n, "A"). By having all the > members refer to the same hash object, Ruby has violated the Priciple > of Least Surprise. Yes, probably it is more consistent in the way Ruby > behaves currently. However, when a person creates an array of hashes, I > don't think there is anybody who wants all the hashes to refer to the same > thing, because it is useless. It prohibits from sharing identical object. Instead, you can: a = (1..2).collect {Hash.new} 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... -- Nobu Nakada