Reference Materials
Certification Courses
Created with over a decade of experience and thousands of feedback.
Swift Set Methods
Set is a collection of unique data. In Swift, there are various set methods that allow us to perform different operations on set. For example, the union() method returns all the elements present in both sets.
In this reference, you will find various set methods that are available in Swift.
returns all elements that satisfies the condition
returns the first element of array
inserts elements of the given sequence into set
inserts a new element at the end of the set
returns true if one set is subset of other
returns true if a set is superset of other set
returns the maximum element in the set
removes the specified element from the set
removes elements from set based on a condition
removes the first element from the set
shuffles all the elements of a set
sorts the elements of the set in a specific order
returns a new set with distinct elements
checks if specified element is present or not
returns the total number of elements present
iterate through each element of a set
forms intersection between two sets
returns new set with elements common to both sets
returns true if two sets are disjoint sets
checks if the set is empty or not
returns the minimum element in the set
returns the set difference of two sets
inserts the given element in the set