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


Example

Using a class Car with an attribute Name.

This OCL if statement checks whether the first car in the collection of all Car instances is null (doesn't exist), and returns an appropriate message based on the result.

if Car.allInstances->first.isNull then
  'No Name for Car'
else
  'Car has Name'
endif