require 'set'
s = [1, 2, 3].to_set OR s = Set.new([1, 2, 3])
union operator:
s | (1..10) (works on anything enumerable)
# Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
difference operator:
products - (3..4)
# Set: {1, 2, 5, 6, 7, 8, 9, 10}
intersection operator:
Set.new(1..3) & Set.new(2..5)
# Set: {2, 3} . (gives elements in common)
exclusive-or operations:
Set.new(1..3) ^ Set.new(2..5)
# Set: {1, 4, 5} (gives elements not in common)