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

intersection(_:)

Returns a new set with the elements that are common to both this set and the given set.

Declaration 宣言

func intersection(_ other: AccessibilityTechnologies) -> AccessibilityTechnologies

Return Value 戻り値

A new set. 新しい集合。

Parameters パラメータ

other

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

Discussion 議論

In the following example, the bothNeighborsAndEmployees set is made up of the elements that are in both the employees and neighbors sets. Elements that are in only one or the other are left out of the result of the intersection.


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