From: matz@... (Yukihiro Matsumoto) Date: 2002-01-25T15:10:42+09:00 Subject: Re: Serious Array Bug in Ruby 1.6.6? Hi, In message "Re: Serious Array Bug in Ruby 1.6.6?" on 02/01/25, Dave Thomas writes: |> > 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? |> |> I thought it too, but the problem is struct RArray has no more |> space to keep the block. Add to aux? | |Would it be bad to add a 'VALUE ifnone' to the end of RArray? It wastes extra 4 bytes for EVERY object, due to RVALUE implementaion. But it's not really a problem, we can use instance variables instead. The point is Hashes (sometimes called "associative arrays") and Arrays are somewhat different. For example, Array#[] provides far more complicated access pattern than Hash#[] (like a[1], a[1,2], a[1..2], a[-3...5]...), and Hash#key? provides the way to check the existence of the key (or index), but there's no counterpart for Array. They are different in Ruby (they are almost same in AWK). And I'm little bit negative about making them look more alike. Giving default value to arrays may bring consistency between Arrays and Hashes, but due to these differences, the consistency may not help people but make them confuse. In addition, as an implementer, I'm afraid that it's really hard to add default value to the current array implementation. I don't think my work is worthy enough. I'm lazy. ;-) matz.