🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
OCLOperators Size () : Integer
This page was created by Peter on 2019-11-25. Last edited by Wikiadmin on 2026-07-29.

Use size() in an OCL or EAL expression when you need an Integer count of the elements in a collection.

Syntax

collection->size()
object.size()

The result is an Integer.

Example

The following expression counts the orders associated with the first customer:

Customer.allInstances->first.Orders->size()

In this expression:

  • Customer.allInstances returns the customers in the system.
  • ->first selects the first customer.
  • .Orders follows that customer's Orders association.
  • ->size() returns the number of order objects in that collection.

Behavior for a single object

If the operand is not already a list, MDriven treats it as a list containing that one element before counting it. The operator is designed to be null-safe in the MDriven/EAL environment.

For the complete operator definition and collection behavior, see size().

See also