🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
OCLOperators :=
This page was created by Hans.karlsen on 2025-05-13. Last edited by Edgar on 2025-08-31.

The assignment operator :=

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

self.Product.RegulatoryAffair:=Biocide.Create

or to a variable:

vSomeDouble:=44/33


Up until 2025-May we had the expression given the type of its right hand side (RHS). But it is now changed to give its 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 collection(Integer)

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

This has partly to do with us 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 to 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 re-written:

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