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

You use create in an OCL expression to create a new instance of a specified class in the current ViewModel or OCL execution scope.

Syntax

<ClassName>.create

Replace <ClassName> with the name of the class that you want to instantiate.

Create an object

  1. Identify the class you need to create.
  2. Write the class name followed by .create.
  3. Use the expression where a new instance is required in the current ViewModel or OCL execution scope.

For example, this expression creates a new Customer object:

Customer.create

The result is a brand-new instance of Customer in the current execution scope.

How the syntax works

Part Meaning
Customer The class or type to instantiate.
.create The OCL operator that creates a new instance of that class.

Use the class name, not an existing object, before .create. In the example, Customer.create creates a customer instance; it does not act on a customer that already exists.

Related operators

create creates an object instance. If you need a new GUID value for a GUID attribute, use newGuid instead. If you need a collection for iteration, see Sequence or Set.

See also