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

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:

Documentation OCLOperators minus 1769493740723.png