Using Ruby 2.4, I have an array of unique, ordered numbers, for example
[1, 7, 8, 12, 14, 15]
How do I find the first two elements whose differ
Simple example
X = [1, 7, 8, 12, 14, 15] X.each_with_index do |item, index| if index < X.count - 1 if (X[index+1]-X[index] == 1) puts item end end end