What is the Kotlin style when writing nested logical operations over multiple lines?

Sorry to get sidetracked, but I hate an operator at the end of a line! Even if your window is wide enough to show it (which isn’t a given), it still takes a lot longer to see the big picture: operators don’t line up, and you need to take in the whole thing before you can make sense of it. Whereas if the operators are at the start of a line, you can get the structure just from glancing at the LHS.

That’s why I think Kotlin’s line-breaking is too eager. IMHO it should assume a semicolon only if it’s necessary to make sense of the line.

Most of the time the ambiguity gives errors, but occasionally it changes the meaning of valid code, e.g.

    val a = (somevariable * someothervariable)
          - (anothervariable * yetanothervariable)

In which, thanks go the magic of the unary minus, the second line is silently ignored!

I can’t imagine a case where two lines could form a single statement, but you wouldn’t want them to.

(So, getting back to the point: @TorRanfelt, I’d encourage you to keep on splitting lines where you do, however much the formatter tries to sabotage it! :smile:)