🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
OCLOperators including
This page was created by Alexandra on 2017-08-14. Last edited by Wikiadmin on 2026-07-29.

You can use including to create a collection that contains every element in an existing collection together with one additional object.

Syntax

collection.including(object)
  • collection is the existing collection, referred to as self in the operator definition.
  • object is the element to add.
  • The result is a collection containing all elements from collection, followed by object.

Example

The following expression returns a collection with all elements of myCollection and newObject included:

myCollection.including(newObject)

OrderedSet limitation

Important: The OCL standard library has a documented issue in which using including on an OrderedSet changes the result into a Set. If your expression relies on the ordering of an OrderedSet, verify the result type and ordering after using including.

See also