From: Ruhe Date: 2008-02-16T23:49:56+09:00 Subject: Iterate through array twice I have array of horizontal segments and I need to find which of them may be sides of a box, so I implemented this method: def find_square_sides(horiz_segments) squares = Array.new horiz_segments.each_with_index do |side, i| horiz_segments[(i+1)..(horiz_segments.size - 1)].each do | condidate| if(## here goes long-long check ##) squares << Square.new(side, condidate) end end end squares end Knowing the beauty of Ruby, I hope that there is a better solution. I guess that double iterating isn't the best.