Documentation Language: Swift

Function

first(_:)

Returns the first element of a collection.

func first(_ collection: any EcoreValue) throws -> any EcoreValue

Parameters

collection

The collection to get the first element from

Return Value

The first element of the collection

Discussion

The first operation returns the first element of a non-empty collection. If the collection is empty, it throws an error.

Examples

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