.isSuperset()
Published Nov 22, 2022
Contribute to Docs
The .isSuperset()
method returns a boolean telling whether every element of a given set exists in another set.
Syntax
setOne.isSuperset(of: setTwo)
The .isSuperset()
method returns true
if setOne
is a superset of setTwo
, false
otherwise.
Example
In the following example, the .isSuperset()
method is used with a conditional expression to print a phrase:
let setOne: Set = ["Apple", "Orange", "Banana", "Kiwi", "Tomato"]let setTwo: Set = ["Orange", "Banana"]if setOne.isSuperset(of: setTwo) {print("setOne is a superset of setTwo.")} else {print("setOne is not a superset of setTwo.")}
This will output the following:
setOne is a superset of setTwo.
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.