Set operation based on array
require 'set' a = [1,2,3] b = [3,4,5] a.to_set ^ b.to_set # => #<Set: {5, 1, 2, 4}> (a | b) - (a & b) # => [1, 2, 4, 5]