From: Jim Weirich Date: 2012-07-31T08:07:31+09:00 Subject: [ruby-core:46880] Re: [ruby-trunk - Feature #6808] Implicit index for enumerations On Jul 30, 2012, at 6:59 PM, trans (Thomas Sawyer) wrote: > > Issue #6808 has been updated by trans (Thomas Sawyer). > > >> There is no such index internal to Enumerator to make accessible. > > It not about Enumerator, its about #each itself. And there certainly is and index with #each method itself. e.g. https://github.com/ruby/ruby/blob/trunk/array.c#L1549 But that's only each for arrays. I doubt an each method for, say, linked lists would bother to implement an internal index. > #each_with_index doesn't cut it at all, as it doesn't address all the other possibilities, #map_with_index, #select_with_index, etc., which is the point. I'm not clear why the #with_index method isn't adequate for your needs. [1,2,3].map.with_index { |item, index| [item, index] } -- -- Jim Weirich -- jim.weirich@gmail.com