Hi -- On Fri, 8 Jul 2005, Michael Campbell wrote: > On 7/8/05, David A. Black <dblack / wobblini.net> wrote: >> Hi -- > >> I'd still like to see #man_with_index added to Enumerable. > > "index" implies an ordering, which maps by definition don't have. > Shouldn't that be something along the lines of "#map_with_key"? > > But point taken; it seems a natural thing, regardless of actual name, > to be in Enumerable. Actually you're right about the ordering, and I think it should not be in Enumerable. Hash#each_with_index has always struck me as pointless for that reason: it just slaps essentially arbitrary integers on an unordered collection. It also has always struck me as odd that Enumerable has #each_with_index but lacks #index. What I'd really like to see would be #each_with_index removed from Enumerable, and pushed down to Array and other classes that need it (like #index), and then #map_with_index added to Array too. I think there's an RCR about this, probably, somewhere... possibly rejected... :-) There's also been a lot of discussion here and elsewhere about things like whether "enumerable" has to mean "associated serially with integers", whether hashes should really be understood as enumerable, whether hash keys are the equivalent of array indices or whether, if hashes have a numerical "index", that index is the equivalent of an array index, and if so, why hashes need that extra layer of indexing, etc. (That's also come up in connection with what an Array#to_hash method would do.) I don't have any definitive answers, but I think there's room to clear up the ambiguous status of the concept "index" as it is manifested in Enumerable. David -- David A. Black dblack / wobblini.net