🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
OCLOperators modulus
Created by Charles on 2025-11-18 · Last edited by Colline.ssali on 2026-01-27.

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:

Documentation OCLOperators modulus 1769508811292.png