Line continuation

Is there a possibility to continue a long if statement in the next line?

Which language? The short answer is yes, of course. But how to do it varies.

And in general, really long if statements are a code smell. There are likely better ways to structure the conditions to simplify.

I have long if statements in openhab rules, because of long item names.

Any solution how to continue lines in openhab rules?

Are you creating rules on OH with Javascript, or are you using the RulesDSL?
Or something completely different like python?

Textual Rules I guess thats RulesDSL

It’s also super helpful if you actually post the code you are talking about rather than have us guess.

In rules DSL anywhere you have a white space you can put a newline instead, though it’s usually best to break it up by condition instead.

    if(MyItem1.state == ON 
       && MyItem2.state > 50
       || (MyItem3.state == OFF && MyItem4.state == ON)) {
        // Do something
    }
3 Likes