Can we initialize local variables inside a dmn using FEEL/Literal expression
if (somecondition) then {
newVar=newVal
}else { }
if(newVar==someVal) then {..}
else {}
Can we initialize local variables and use them the way it is done in OOP? I need to utilize the local variable, I do not intent to use BKM here.
DMN FEEL is an expression language and as such it does not have statements, specifically variable assignment statements.
This is indeed a typical statement in java such as
and being a statement is not available in the FEEL expression language.
That said, in special scenarios, you might use an helpful trick of inlining a FEEL context to mimic similar behaviour.
Something ~like:
For example:
if supplied with
a number
would result in the value"positive"
or"negative"
FEEL string, with no trace of thenewVar
or the"pos"
or"neg"
in the final result.Demo: