firstMatchValue = -1array1 = [1, 2, 3]array2 = [2, 3, 4]catch (:done) do for i in array1 for n in array2 if i == n firstMatchValue = i throw :done end end endend# firstMatchValue is 2puts firstMatchValue