🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
OCLOperators first
Created by Alexandra on 2017-08-13 · Last edited by Vale.buyondo on 2025-12-13.

The first operator returns the first element in the collection it is applied to.If the operand is not already a collection, it is converted to a list before evaluation.

Syntax

collection->first

Examples

Customer.allInstances->first

Returns the first Customer object in the system.

self.Orders->first

Returns the first Order linked to the current Customer

Customer.allinstances->select(a|a.Age>50)->first

Returns the first Customer older than 50