On 2/5/06, jonT <j / tippell.com> 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