OCL–when do I use arrow (->) and when do I use dot (.) ?

The dot and arrow is almost interchangeable – but “–>” is used for operators and “.” is used for navigations.

In ocl you use the arrow when you want to act (use an operator) on the container of the thing(s)

You use the dot when navigating on the model object or element (classes, tuples, attributes)



SomeClass.allinstances  – the operator acts on the Class SomeClass and returns a list containing objects of type SomeClass.

To select some objects from this list I apply the select operator to the list that CONTAINS the SomeClass objects


But if I wanted to get a collection of booleans I could as the for the Heavy attribute of the CONTENTS of the collection:


If I want to know how many values this new collection has then I must ask the list – and as the list is the CONTAINER of the objects I use arrow –>

SomeClass.allinstances.Heavy->size  – this will return a single Integer

SomeClass.allinstances.Heavy.size  – will not work since the Heavy attributes does not have a size operator – but a collection of Heavy attributes does.



Think of the box below as the collection

And the circles within as objects in the collection


Things on objects: Use dot

Things on container (collection or SingleLink ) : Use Arrow


Things like –>isEmpty is always on the container, but .isnull ask if a specific object(or attribute or something) represents the nullvalue of that type.


An OCL-parser implementation is forgiving and will not harass you for using –> as navigations. It just thinks that you are asking for the container of that single object or attribute – and technically a single thing can be considered to be its own container – so –> will be treated as .

This entry was posted in Uncategorized and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.