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