The formIntersection() method removes the elements of the set that aren't also in the given sequence.
Example
formIntersection() Syntax
The syntax of the set formIntersection() method is:
set.formIntersection(otherSequence)
Here, set is an object of the Set class.
formIntersection() Parameters
The formIntersection() method takes a single parameter:
- otherSequence - The sequence (mostly arrays and sets) of elements.
Note: The other must be a finite set.
formIntersection() Return Value
- The
formIntersection()method doesn't return any value.
Example: Swift Set formIntersection()
Output
New A: ["c"] New B: ["c", "b"]
Here, we have used the formIntersection() method to remove the elements that aren't common to both set and the given sequence and finally print the newly updated sets A and B.