🚀 Welcome to MDriven Learn –  Don’t miss the latest Release Notes.
OCLOperators unary-

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)