The emptyList operator creates a new, empty collection of the specified type. This is essential in OCL because the language is strongly typed; even an empty collection must "know" what type of objects it is designed to hold.
It is particularly useful in conditional logic (if-then-else) where both branches must return the same type of collection, or when you need to "reset" a collection variable in an action
Syntax
ClassName.emptyList
Example
let myResults = Customer.emptyList in myResults->union(Customer.allInstances->select(c | c.Balance > 100))
If matching customers exist: It returns a list containing every Customer instance where the Balance attribute is greater than 100
If no customers match: It returns an empty collection of type Customer
The "Type" of the result: Even if the list is empty, the system recognizes it as Collection(Customer), allowing you to safely call further operators like ->count or ->first without a type error.
