You use := in EAL action expressions to assign a value to a property or variable; this page is for developers who need to understand the value and type returned by an assignment.
Assign a value
The assignment operator := writes the value on its right-hand side (RHS) to the property or variable on its left-hand side (LHS).
self.Product.RegulatoryAffair:=Biocide.Create
In this example, the newly created Biocide is assigned to RegulatoryAffair on self.Product.
You can also assign to a variable:
vSomeDouble:=44/33
Result type of an assignment
An assignment expression has the type of its left-hand side. This rule applies from 2025-May.
For example, if SomeDouble has type Double, the assignment below has type Double:
x.SomeDouble:=4
The integer literal 4 can be assigned to the Double property. The assignment result is nevertheless typed as Double, because SomeDouble is the LHS.
Use assignment in a collection expression
The LHS type rule is important when an assignment is evaluated inside a collection operation. For example:
somelist->collect(x|x.SomeDouble:=4)
If SomeDouble is a Double, collect produces a collection of Double. It does not produce a collection of Integer merely because 4 is an integer literal.
When the assigned value has a more specific type
The assignment result can be less specific than the object created on the RHS. This occurs when the LHS property is declared as a superclass.
Assume that RegulatoryAffair is a superclass of Biocide:
self.Product.RegulatoryAffair:=Biocide.Create
The expression above now has type RegulatoryAffair, not Biocide. Before 2025-May, it was typed from the RHS and therefore had type Biocide.
If the following expression needs a Biocide, use one of these patterns.
Cast the assignment result
Use safeCast when you need the assignment expression itself to be treated as Biocide:
(self.Product.RegulatoryAffair:=Biocide.Create).safeCast(Biocide)
Keep the created object in a variable
Use a let expression when you want to retain the created object's specific type without casting the assignment result:
let x:=Biocide.Create in(
self.Product.RegulatoryAffair:=x;
x
)
Here, x has type Biocide. The assignment stores x in the RegulatoryAffair property, and the final x expression returns the Biocide value.
Choose the right pattern
| Your need | Pattern | Result type |
|---|---|---|
| Assign a value and use the property's declared type | property:=value
|
The type of property
|
Assign a value in collect and retain the property element type
|
x.SomeDouble:=4) | The type of SomeDouble
|
| Assign a derived object and continue as the derived type | (property:=Derived.Create).safeCast(Derived)
|
Derived
|
| Create once, assign it, and return the derived object | let x:=Derived.Create in(property:=x; x)
|
Derived
|
Migration guidance for expressions written before 2025-May
Review assignments where the RHS is more specific than the LHS property, especially assignments followed by an operation available only on the derived type.
- Find an expression of the form
SupertypeProperty:=Derived.Create. - Check whether later parts of the expression require the
Derivedtype. - If they do, add
safeCast(Derived)to the assignment result, or create the object in aletvariable and return that variable. - If later code only needs the declared property type, no change is needed.
