func union(Self) -> Self
A set of the same type as the current set. 現在の集合と同じ型の集合。
Availability
Technology
func union(_ other: Self) -> Self
other
A set of the same type as the current set. 現在の集合と同じ型の集合。
A new set with the unique elements of this set and other
.
この集合とother
との特有な要素を持つ新しい集合。
In the following example, the attendees
set is made up of the elements of the attendees
and visitors
sets:
以下の例において、attendees
集合はattendees
とvisitors
集合の要素から作り上げられます:
let attendees: Set = ["Alicia", "Bethany", "Diana"]
let visitors = ["Marcia", "Nathaniel"]
let attendeesAndVisitors = attendees.union(visitors)
print(attendeesAndVisitors)
// Prints "["Diana", "Nathaniel", "Bethany", "Alicia", "Marcia"]"
If the set already contains one or more elements that are also in other
, the existing members are kept.
other
の中にもある1つ以上の要素をこの集合がすでに含むならば、既存のメンバはそのままにしておかれます。
let initialIndices = Set(0..<5)
let expandedIndices = initialIndices.union([2, 3, 6, 7])
print(expandedIndices)
// Prints "[2, 4, 6, 7, 0, 1, 3]"
Note 注意
if this set and other
contain elements that are equal but distinguishable (e.g. via ===
), which of these elements is present in the result is unspecified.
この集合とother
が等しいけれども区別可能な要素を含むならば(たとえば===
によって)、それらの要素のどれが結果の存在するのかは不特定です。
func union(Self) -> Self
func formUnion (Self)
func intersection(Self) -> Self
func formIntersection (Self)
func symmetricDifference (Self) -> Self
func formSymmetricDifference (Self)