From: Derek Cannon Date: 2009-12-13T20:27:34+09:00 Subject: Code block for element comparison in an array? I'm new to Ruby and I can't think of how to do this! I would like each element in an array to compare itself with all its proceeding elements. For example: In an array of 10 elements, a[0] will be compared to a[1] ... a[9] a[1] will be compared to a[2] ... a[9] ... a[9] will not be compared, as there is nothing larger than it. For those who don't understand, I think the Java/C++ equivalent would be: for(int i=0; i < array.length; i++) { for(int j=i+1; j < array.length; j++) { // Compare array[i] with array[j] } } -- Posted via http://www.ruby-forum.com/.