I have two arrays
array_input = %w[one two three two]
array_compare = %w[one two three four five]
I want to extract the 'highest' index from the array_compare array, if the value exists in the input array. The desired output is 2 as three exists in the input array and the compare array.
I've tried
val = nil
array_compare.reverse_each do |v|
val = v and break if array_input.include? v
end
but it does not set val.