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

You can use includes in OCL to test whether a value is contained in another value, such as whether a car name contains the text Toyota.

Syntax

self.includes(object)

self is the value you search in. object is the value you look for. The expression returns a Boolean value:

Result Meaning
true object is contained in self.
false object is not contained in self.

Find a name containing Toyota

Given a Car class with a Name attribute, use includes on the name when you need to test for the text Toyota:

Name.includes('Toyota')

This expression returns true for a name such as Toyota Corolla. Use the resulting Boolean expression where your OCL requires a condition—for example, when evaluating whether a car's name contains that text.

Case sensitivity

includes is case-sensitive. The search text must use the same letter case as the text being tested.

Name value Expression Result
Toyota Corolla Name.includes('Toyota') true
Toyota Corolla Name.includes('toyota') false

When you combine this result with other conditions, use the Boolean operators described in Documentation:OCL Boolean Operators.

See also