From: William Djaja Tjokroaminata Date: 2002-01-26T02:12:06+09:00 Subject: Re: Serious Array Bug in Ruby 1.6.6? It "does not work" because the purpose is to create an array of hashes and not an array of a single hash. Yes, there are many options in a language, but which ones are the most useful? Probably x = x is not useful. Now, for a = Array.new (n, Hash.new), which one is more useful, for it to create a single hash or multiple hashes? I make a hypothesis that if we change the behavior of Array.new (using Object#dup or clone), it will not break many existing codes, because for people who wrote a = Array.new (n, 'a') it still works while I don't think anybody has ever written a = Array.new (n, Hash.new) (except myself, of course). If anyone has found the usefulness of Array.new (n, Hash.new) or Array.new (n, Array.new), please let me know. Regards, Bill ======================================================================== David Alan Black wrote: > This is sort of a circular argument.... You've listed Array.new(2, > Hash.new) as one of the options for creating an array of two different > hashes, and then declared that the construct "does not work". But > actually it does work precisely as documented. I know that your point > is that you wish it behaved differently, but that's different from not > working :-) > I've never used it, but then again I don't think every possible > statement based on a language's semantics has to have a purpose that's > defineable in advance. You could put: > x = x > somewhere in a program, and it wouldn't serve any purpose, but that > doesn't mean that the language's support for assignment to variables > should be reconsidered. (Sort of a reductio ad absurdum, I admit, but > still I think the principle might apply.)