Instance Methodswift 6.0.1Swift

    subtracting(_:)

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

    func subtracting(_ other: Set<Element>) -> Set<Element>

    Parameters

    other

    Another set.

    Returns

    A new set.

    In the following example, the nonNeighbors set is made up of the elements of the employees set that are not elements of neighbors:

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

    Other members in extension

    Types

    Type members

    Instance members