Lou Scoras wrote: > require 'enumerator' > class Array > def find_my_index(x,y) > to_enum(:each_with_index).each_cons(2) {|(a,i),(b,_)| > return i if a == x && b == y > } > nil > end > end I prefer to leave the actual searching to the Array class. Who knows, it might cache a partial-order tree representation of the array and use some micro-optimized search algorithm that performs O(log n) on average? Here is a short one-line solution in that spirit: class Array def find_my_index x, y i = index(x) and self[i+1] == y and i end end Here is a more human readable version, if you don't mind two extra lines: class Array def find_my_index x, y if i = index(x) and self[i+1] == y i end end end -- Posted via http://www.ruby-forum.com/.