From: William Djaja Tjokroaminata Date: 2002-01-25T23:51:58+09:00 Subject: Re: Serious Array Bug in Ruby 1.6.6? We all know in a = 125 b = 125 a and b point to the same object. But in a = [] b = [] a and b do not point to the same object. Therefore, can't we just simply define class Array def initialize (n, obj = nil) internalArray = ... for i in 0...n internalArray[i] = obj.dup end end end ? This is the one in my head. I'm sorry that I have some C++ background with its deep copy feature, while Ruby has only shallow copy. My question is in the usefullness. Nobody will write h = Hash.new Array.new(2,h) Regards, Bill =========================================================================== > The way I see it. > Array.new(2,Hash.new) is the same as > h = Hash.new > Array.new(2,h) > and that's very clear. It would break my POLS if it was in anotherway. > Also trying to eval this by hand trying to guess how the interpeter does > it would be like this > Array.new(2, Hash.new) -> Array.new(2, {}) # that is.. Hash.new is done > before Array.new. I don't know if this is what happens but in my head > that's it :) > Now, I really think that what you want to do should be possible but it > shouldn't be in that way. > /Erik