David Alan Black <dblack / candle.superlink.net> writes:

> I guess h.each_with_index is, in effect, shorthand for
> h.entries.each_with_index, since the data structure that's being
> indexed is not the hash but the array returned by Hash#entries.

I think it could also be the other way around: each_with_index returns 
key/value pairs out of the hash, and #to_a performs an (artificial)
flattening on the hash into an array.

Internally, hashes are not arrays, they're.... hashes.

If we've saying that anything that can be indexed is an array, then I
guess we should include files, directories, strings, ...  Similarly is
we're saying that anything with keys is a Hash.

Arrays and hashes have similar properties, but are different beasts,
In the same way that the old OO argument of Squares and Rectangles
can't be resolved by answering a Square is a kind of Rectangle, or a
Rectangle is a kind of Square, so too is it impossible to say that an
Array is a kind of Hash or a Hash a kind of Array. It seems to me that
they just share some properties.


Regards


Dave