🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
OCLOperators unary-
Created by Stephanie on 2025-01-06 · Last edited by Sandra.akech on 2025-12-12.

The "unary-" operator in OCL (Object Constraint Language) is simply the negative sign you put in front of a number to make it negative. The term "unary" just means it acts on one value (unlike a "binary" operator like + or - that acts between two values).


Examples:

Expression:

-(3 + 2)
  • Compute (3 + 2) = 5
  • Unary minus makes it -5


Precedence:

Unary minus has higher precedence than addition or binary minus.


Example:

-3 + 2
  • Interpreted as (-3) + 2 = -1
  • Not as -(3 + 2)