I need to check whether two arrays contain the same data in any order. Using the imaginary compare method, I would like to do:
compare
arr1 = [1,2,3,5,4
The most elegant way I have found:
arr1 = [1,2,3,5,4] arr2 = [3,4,2,1,5] arr3 = [3,4,2,1,5,5] (arr1 - arr2).empty? => true (arr3 - arr2).empty? => false