🚀 Welcome to MDriven Learn –  Don’t miss the latest Release Notes.
OCLOperators :=

The assignment operator :=

It is part of the EAL Action language and is a way to actually assign a value to object properties:

self.Product.RegulatoryAffair:=Biocide.Create

or to a variable:

vSomeDouble:=44/33


Up until 2025-May, the expression was given the type of its right-hand side (RHS). But it has now been changed to give it the type of its Left hand side (LHS).

The reason for this change comes from this case:

somelist->collect(x|x.SomeDouble:=4)

In the case above, 4 is interpreted as an integer—and if you use RHS, the whole expression will be a collection(Integer)

But the list will really be a list of SomeDouble, which we assume is of type Double.

This has partly to do with our allowing up-typing of int to double in assign—a good practice that we will keep.

It is better if we treat the assign operator := as LHS typed for this case...

But then we saw these cases:

self.Product.RegulatoryAffair:=Biocide.Create

and here RegulatoryAffair is a superclass of Biocide—and the expression was of type Biocide prior to our change from RHS to LHS—and after the change it is of type RegulatoryAffair. This will require these expressions to be rewritten:

to this

(self.Product.RegulatoryAffair:=Biocide.Create).safeCast( Biocide)

or this

let x:=Biocide.Create in(
  self.Product.RegulatoryAffair:=x;
   x
)

Question to Co-pilot:  Should the result type of assign operator := be the type of the LHS or RHS?  I am gonna go with LHS and thus force some expressions to write a cast to get what they need in return type

Answer: That sounds like a solid and principled decision. By going with LHS-typed assignment, you're prioritizing type safety and predictability, which are especially important in statically typed or strongly inferred languages