assignment

Syntax

variableName = value;
or
expression.propertyName = value;

where:

Description

This statement enables to create a new variable (or to replace an existing variable), or to change the value of a model element property.

The specified property name must resolve to a setter method defined on the assignment expression receiver:
myClass.name = "hello" is equivalent to myClass.setName("hello").

Examples

Creates a String variable and initializes its value:

myString = "Hello World";

Creates a List variable and initializes its value:

seasons = ["winter", "spring", "summer", "autumn"];

Changes the name of a class:

class.name = "Hello";
// equivalent to class.setName("Hello");

Changes the namespace of an attribute's type:

myAttribute.type.namespace = myPackage;
// equivalent to myAttribute.getType().setNamespace(myPackage);