From: Sam Roberts Date: 2003-04-27T01:31:45+09:00 Subject: Re: Hashes and Enumerable#each_with_index Quoteing rpav@nwlink.com, on Fri, Apr 25, 2003 at 07:26:01AM +0900: > OK, looking at the archives I know this was discussed a few years ago, > but there seems to be no real conclusion or improvement since then. > > The problem: Hash#each_with_index returns an index that is not usable > to address the hash. That is, given the following: > > h = Hash.new > h.each_with_index { > | o, i | > ... > } > > i is not defined such that h[i] == o, which is both misleading and > seemingly useless. (This behavior, as per the previous discussion, can > be achieved with h.to_a.each_with_index.) This function already exists, for a Hash its called Hash#each. I guess Hash could override the each_with_index it gets from enumerable, aliasing it to each, but that seems like it would be LESS useful, not more useful. Sam