🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
OCLOperators if
Created by Stephanie on 2025-01-08 · Last edited by Peter.byaruhanga on 2026-01-05.


Example

Using a class Car with attributes 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