From: Michel Demazure Date: 2010-10-11T18:27:39+09:00 Subject: Testing for subarrays I want to check whether a given array contains a given subarray and return the corresponding range. Is there a builtin method ? If not, do you have better than this : class Array def look_up(sub_array) len = sub_array.size self.each_cons(len).with_index do |cons, index| return Range.new(index, index + len - 1) if cons == sub_array end nil end end _md -- Posted via http://www.ruby-forum.com/.