first

Full name: taxi.stdlib.first

Signature

declare extension function <T> first(collection: T[]):T

Description

Returns the first item within the collection. Throws an error if the collection is empty.

This function retrieves the first element in an ordered collection.

// Get the most recent transaction from a sorted list
find { account: Account } as {
   latestTransaction: account.transactions.first()
}

Examples

This example demonstrates how to use first() to retrieve the most recent transaction for an account.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed
Next
Welcome to Taxi