Documentation Language: Swift

Function

asSet(_:)

Converts a collection to a set by removing duplicates.

func asSet(_ collection: any EcoreValue) throws -> [any EcoreValue]

Parameters

collection

The collection to convert

Return Value

A new array with duplicates removed

Discussion

The asSet operation creates a new collection with duplicate elements removed, preserving the order of first occurrence.

Examples

let numbers = [1, 2, 2, 3, 3, 3] as [EInt]
let uniqueNums = try asSet(numbers)  // Result: [1, 2, 3]