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

Symbol (-)

In OCL, the minus operator (-) is an arithmetic operator used to perform subtraction between two numeric values. It is also used as a unary operator to indicate a negative value. This operator is commonly used in calculations, derived attributes, and constraints.

Basic Syntax

a - b

Example:

Assume the Department class has:

Budget : Double

Spent : Double

self.Budget - self.Spent

This calculates how much budget remains.


Using Minus with a Department Collection

Department.allInstances
  ->collect(d | d.Budget - d.Spent)

Results:

Error creating thumbnail: File missing