The isSuperset() method returns true if a set has every element of another set (passed as an argument). If not, it returns false.
Example
isSuperset() Syntax
The syntax of the set isSuperset() method is:
set.isSuperset(otherSet)
Here, set is an object of the Set class.
isSuperset() Parameters
The isSuperset() method takes a single parameter:
- otherSet - The set of elements.
isSuperset() Return Value
- The
isSuperset()method returnstrueif set is a superset of otherSet. If not, it returnsfalse.
Example: Swift Set isSuperset()
Output
true false
Here, we have used the isSuperset() method to check if one set is a superset of another or not.
Since
- employees is a superset of developers, the method returns
true. - employees is not a subset of designers, the method returns
false.