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

symmetricDifference(_:)

Returns a new set with the elements that are either in this set or in the given set, but not in both. この集合の中か与えられた集合の中かどちらかの、しかし両方の中にではない要素を持つ新しい集合を返します。

Declaration 宣言

func symmetricDifference(_ other: Self) -> Self

Parameters パラメータ

other

A set of the same type as the current set. 現在の集合と同じ型の集合。

Return Value 戻り値

A new set. 新しい集合。

Discussion 解説

In the following example, the eitherNeighborsOrEmployees set is made up of the elements of the employees and neighbors sets that are not in both employees and neighbors. In particular, the names "Bethany" and "Eric" do not appear in eitherNeighborsOrEmployees. 以下の例において、eitherNeighborsOrEmployees集合はemployeesneighbors集合の要素で、employees および neighborsの両方の中にはないものから作り上げられます:個別的には、名前"Bethany""Eric"は、eitherNeighborsOrEmployeesの中に現れません。


let employees: Set = ["Alicia", "Bethany", "Diana", "Eric"]
let neighbors: Set = ["Bethany", "Eric", "Forlani"]
let eitherNeighborsOrEmployees = employees.symmetricDifference(neighbors)
print(eitherNeighborsOrEmployees)
// Prints "["Diana", "Forlani", "Alicia"]"

Default Implementations 省略時実装

OptionSet Implementations

See Also 参照

Combining Sets 集合を結合する