Documentation Language: Swift

Function

last(_:)

Returns the last element of a collection.

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

Parameters

collection

The collection to get the last element from

Return Value

The last element of the collection

Discussion

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

Examples

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