DMN FEEL is an expression language and as such it does not have statements, specifically variable assignment statements.
Can we initialize local variables and use them the way it is done in OOP?
This is indeed a typical statement in java such as
String name = "John Doe";
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:
{
newVar: if (somecondition) then ... else ... ,
result: if (newVar=someVal) then ... else
}.result
For example:
{
newVar: if (a number > 0) then "pos" else "neg" ,
result: if (newVar="pos") then "positive" else "negative"
}.result
if supplied with a number
would result in the value "positive"
or "negative"
FEEL string, with no trace of the newVar
or the "pos"
or "neg"
in the final result.
Demo:
