Instance Method

subtract(_:)

Removes the elements of the given set from this set.

Declaration

mutating func subtract(_ other: GestureMask)

Parameters

other

A set of the same type as the current set.

Discussion

In the following example, the elements of the employees set that are also members of the neighbors set are removed. In particular, the names "Bethany" and "Eric" are removed from employees.

var employees: Set = ["Alicia", "Bethany", "Chris", "Diana", "Eric"]
let neighbors: Set = ["Bethany", "Eric", "Forlani", "Greta"]
employees.subtract(neighbors)
print(employees)
// Prints "["Diana", "Chris", "Alicia"]"

See Also

Adding and Removing Elements

func update(with: GestureMask) -> GestureMask?

Inserts the given element into the set.

func insert(GestureMask) -> (inserted: Bool, memberAfterInsert: GestureMask)

Adds the given element to the option set if it is not already a member.

func subtracting(GestureMask) -> GestureMask

Returns a new set containing the elements of this set that do not occur in the given set.

func remove(GestureMask) -> GestureMask?

Removes the given element and all elements subsumed by it.