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

formSymmetricDifference(_:)

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

Declaration 宣言

mutating func formSymmetricDifference(_ other: Set<Element>)

Parameters パラメータ

other

Another set. もう一方の集合。

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 "Alicia", "Chris", and "Diana" are removed from employees while the names "Forlani" and "Greta" are added. 以下の例において、employees集合の要素でまたneighborsのメンバであるものはemployeesから削除されます、一方でneighborsの要素でemployeesの要素でないものはemployeesに加えられます。個別的には、名前"Alicia""Chris"、そして"Diana"は、employeesから削除される一方で名前"Forlani""Greta"は加えられます。


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

Relationships 関係

From Protocol 由来プロトコル

See Also 参照

Combining Sets 集合を結合する