From: Dave Thomas Date: 2003-04-25T15:55:06+09:00 Subject: Re: Hashes and Enumerable#each_with_index Yukihiro Matsumoto wrote: > * each_with_foo should be available for all built-in classes that > have obj[x] access. > > * each_with_foo must give (x,y) that obj[y] == x be true always. > > Replace "foo" with the right word. I don't think it's "key", since > Array index is not key after all. Or, have each class that wants to support this protocol define a method 'each_foo'. Then have enumerable implement 'each_with_foo' as module Enumerable def each_with_foo each_foo {|foo| yield self[foo], foo} end end Then the change to Hash is simply alias each_foo each_key and to array alias each_foo each_index However, how often to you want to do an each_with_index polymorphically? Cheers Dave