Mega Code Archive
Categories
/
Ruby
/
Collections
The intersection is the set of values that appear in both
require 'set' primes = Set[2, 3, 5, 7] odds = Set[1, 3, 5, 7, 9] p primes & odds # => #
p primes.intersection(odds) # this is an explicitly named alias