getAtIndex

Full name: taxi.stdlib.getAtIndex

Signature

declare extension function <T> getAtIndex(collection: T[], index: Int):T

Description

Returns the item at the provided index in the collection. Throws an error if the index is out of bounds.

This function retrieves an element at a specific position in a collection, with zero-based indexing.

// Get the second item in a list
find { playlist: Playlist } as {
   secondSong: playlist.songs.getAtIndex(1) // Note: index starts at 0
}

Examples

Retrieves a song from a playlist by its zero-based index position.

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