Perform an Intersection on Two Sets of Data
In this exercise we are going to perform an intersection on 2 sets of data. We
will create a method on our Set
data structure called intersection
. An
intersection of sets represents all values that are common to two or more sets.
This method should take another Set
as an argument and return the
intersection
of the two sets.
For example, if setA = ['a','b','c']
and setB = ['a','b','d','e']
, then the
intersection of setA and setB is: setA.intersection(setB) = ['a', 'b']
.
Test
{{test}}Console output