From: Levin Alexander Date: 2006-02-06T00:02:35+09:00 Subject: Re: Ruby feature request - enum.detect_index On 2/5/06, jonT wrote: > I'd like to propose a new addition to the enum module.>> detect works great but doesn't supply the index of the match. It would> be nice to have a method detect_index that returned the index rather> than the object. You can do it with enumerator: require 'enumerator' [1,2,3,4,5,6].to_enum(:each_with_index).detect {|elem, index| elem== 4} #=> [4,3] (enumerator is probably the one library in the stdlib I use most. Itis amazingly useful) -Levin