map

Full name: taxi.stdlib.map

Signature

declare extension function <T,A> map(collection: T[], callback: (T) -> A):A[]

Description

Applies a transformation function to every element in a collection, returning a new array of the results.

If the callback is a type expression, each element is converted to that type:

// Convert Person[] to Name[]
Person[].map((Person) -> Name)

If the callback is any other expression, it is evaluated against each element:

// Return an array of uppercased titles
Film[].map((Title) -> Title.upperCase())

Examples

Extracts a field from each object in a collection, returning a typed array.

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