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

Note: This is an Executable Action Language operator


The foreach operator iterates over a collection without transforming it.It is mainly used toperform side effects (such as delete, clear, assignments, or other actions) while returning the original collection unchanged

Syntax

collection->foreach(item | expression)

Example

Delete all Orders for a Customer (Action)

self.Orders->foreach(o | o.delete)

Deletes every Order associated with the current Customer.

To iterate and return a list as the result, use collect.