+ 3

Why is the answer 2?

What is the output of the following code? let a: Set = ["A", "B", "C"] let b: Set = ["B", "D", "E", "A"] print(b.subtract(a).count)

9th May 2017, 8:01 PM
Janet Hamrani
1 Answer
+ 19
b.subtract(a) returns the elements that are contained in b, but not in a, which are the elements D and E. count returns the number of elements that are returned from the subtract method.
9th May 2017, 8:08 PM
Tashi N
Tashi N - avatar