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

formSymmetricDifference(_:)

Removes the elements of the set that are also in the given set and adds the members of the given set that are not already in the set. 与えられた集合の中にもあるこの集合の要素を削除します、そして与えられた集合のメンバでこの集合の中にはまだないものを加えます。

Declaration 宣言

mutating func formSymmetricDifference(_ other: Self)

Parameters パラメータ

other

A set of the same type. 同じ型の集合。

Discussion 解説

In the following example, the elements of the employees set that are also members of neighbors are removed from employees, while the elements of neighbors that are not members of employees are added to employees. In particular, the names "Bethany" and "Eric" are removed from employees while the name "Forlani" is added. 以下の例において、employees集合の要素でまたneighborsのメンバであるものはemployeesから削除されます、一方でneighborsの要素でemployeesの要素でないものはemployeesに加えられます。個別的には、名前"Bethany""Eric"employeesから削除される一方、名前"Forlani"は加えられます。


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

Default Implementations 省略時実装

OptionSet Implementations

See Also 参照

Combining Sets 集合を結合する