Mega Code Archive

 
Categories / Ruby / Collections
 

The union is the set of values that appear in either

require 'set' primes = Set[2, 3, 5, 7] odds = Set[1, 3, 5, 7, 9] p primes | odds             # => #<Set: {5, 1, 7, 2, 3, 9}> p primes.union(odds)        # an explicitly named alias