Documentation Language: Swift

Function

difference(_:_:)

Returns the difference between two collections.

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

Parameters

left

The first collection (minuend)

right

The second collection (subtrahend)

Return Value

A new array containing elements in left but not in right

Discussion

The difference operation returns elements that are in the left collection but not in the right collection.

Examples

let set1 = [1, 2, 3, 4] as [EInt]
let set2 = [2, 3] as [EInt]
let diff = try difference(set1, set2)  // Result: [1, 4]