OCLOperators not equal to
Created by Charles on 2025-11-18 · Last edited by Colline.ssali on 2026-01-29.
Symbol (<>)
The <> operator is a comparison operator used to check whether two values are not equal. It returns a Boolean result (true or false) and is commonly used in OCL constraints and validation rules.
Assume the Department class has an attribute called DepartmentName.
Department.allInstances->forAll(d | d.DepartmentName <> 'Projects')Results:
What this means
- The expression returns true only if every Department has a name different from Projects
- If even one Department has the name Projects, the result is false
