From: jmichel@... (Jean Michel) Date: 2001-02-22T22:40:03+09:00 Subject: [ruby-talk:11309] Re: musings about Hash#each_with_index In article , Dave Thomas wrote: >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. Watch out here! The fact that you can consider an array as a special case of a hash, of for that matter a string or a file or a directory as a special case of an array is much more than just an analogy. The set of properties which is shared in these cases is an extremely important programming paradigm, and a language which can express clearly this paradigm in a uniform way in all cases will have a definite advantage. I think the mixins that matju is trying to make can potentially achieve this for Ruby. Best regards, Jean MICHEL