🚀 Welcome to MDriven Learn –  Don’t miss the latest Release Notes.
OCLOperators modulus
This page was created by Charles on 2025-11-18. Last edited by Restore-user on 2026-10-21.

Symbol (%)

In OCL, the modulus operator (%) is an arithmetic operator used to return the remainder after dividing one integer by another integer. It is especially useful for cyclic logic, grouping, and parity checks (odd/even).

Basic Syntax:

a mod b

Example: Using the Department Class with an EmployeeCount attribute

self.EmployeeCount mod 2 = 0

This returns true if the employee count is even.


Using Modulus with a Department Collection

Department.allInstances
  ->select(d | d.EmployeeCount mod 2 = 1)

Results:

Error creating thumbnail: File missing