From: Yukihiro Matsumoto Date: 2004-09-21T12:18:13+09:00 Subject: Re: Array#index block and rdetect Hi, In message "Re: Array#index block and rdetect" on Tue, 21 Sep 2004 10:56:51 +0900, "David A. Black" writes: |Here's one possibility. I don't think this would be bad for |compatibility, because Array would have its *_index methods, and I |don't think #each_with_index is used much (ever?) for anything except |arrays and maybe array subclasses. | | Enumerable: | | each_with_counter # "dumb" counters, for every enumerable, | each_counter # strictly based on incrementing through | # #each No need for each_counter, for there's no way for general enumerables to map from counters to values. If it's possible, it's rather suitable to be called as index. By the way, do you agree with the word 'counter'? It's kinda burden for me, non English speaker, to tell the word nuance. | Array: | | each_with_index # either very similar to, or identical to, | each_index # the *_counter methods (because that | # happens to be how arrays work). No objection here. | Hash and other enumerable classes: | | In addition to the *_counter methods, each enumerable class | can have its own, "smart" methods (just as Array does with | its *_index methods). They can have "index" in the name, | if appropriate -- but they do not have to. (There are no | Enumerable#*_index methods.) Do you have any opinion toward Hash#each_with_index? matz.