Instance Method インスタンスメソッド

subtracting(_:)

Returns a new set containing the elements of this set that do not occur in the given set. 与えられた集合の中の現れないこの集合の要素を含んでいる新しい集合を返します。

Declaration 宣言

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

Parameters パラメータ

other

Another set. もう一方の集合。

Return Value 戻り値

A new set. 新しい集合。

Discussion 解説

In the following example, the nonNeighbors set is made up of the elements of the employees set that are not elements of neighbors: 次の例において、nonNeighbors集合はemployees集合の要素で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"]"

Relationships 関係

From Protocol 由来プロトコル

See Also 参照

Combining Sets 集合を結合する