Documentation Language: Swift

Function

union(_:_:)

Returns the union of two collections.

func union(_ left: any EcoreValue, _ right: any EcoreValue) throws -> [any EcoreValue]

Parameters

left

The first collection

right

The second collection

Return Value

A new array containing the union of both collections

Discussion

The union operation combines two collections, removing duplicates. The result contains all unique elements from both collections.

Examples

let set1 = [1, 2, 3] as [EInt]
let set2 = [3, 4, 5] as [EInt]
let combined = try union(set1, set2)  // Result: [1, 2, 3, 4, 5]