Function
including(_:_:)
Returns a new collection with an element added.
func including(_ collection: any EcoreValue, _ element: any EcoreValue) throws -> [any EcoreValue]
Parameters
collection-
The original collection
element-
The element to add
Return Value
A new array with the element added
Discussion
The including operation creates a new collection containing all elements from the original collection plus the new element. If the element already exists, it may appear multiple times.
Examples
let numbers = [1, 2, 3] as [EInt]
let withFour = try including(numbers, 4 as EInt) // Result: [1, 2, 3, 4]