Help with shorthand if else expression

Hello all ,

I want to write this code in single line like so

val DateTime dateTimePlusWait01 = new DateTime(CoolingActionStart01.state.toString ?? now)

if CoolingActionStart01.state.toString is null or not defined, use now

It never is (unless you have no Item by that name). Items are not variables, and are always initialized. An Item may however have a state of NULL or UNDEF to indicate indeterminate.
That usually leads to expressions like
if (myItem.state == NULL || myItem.state == UNDEF) ...

Ternary expressions in DSL rules use keywords if-else, not ??

var xx = if (expression true) valueX else valueY

3 Likes

Thanks @rossko57