Following up the conversation above about string c...
# codingconventions
k
Following up the conversation above about string concatenation formatting, I tried using
+
on new lines as @gabrielfv suggested:
Copy code
foo("one"
    + "two"
    + "three")
only to find that it doesn’t work with
return
, e.g. the following doesn’t compile because of
+
on new line:
Copy code
fun bar(): String {
    return "one;"
        + "two;"
        + "three"
}
I’d argue this means that
+
and
.plus()
are already different enough to have different formatting 🙂 /cc @kevinmost 1 reply I don't know that that necessarily means they should be formatted differently. The only reason that that doesn't work the way you expect is because it resolves as
return "one"
and
+"two"
(the
unaryPlus
operator) So a new unary operator call should definitely not be further indented, but if you mean it to be a binary
plus
operator, you should definitely indent it to indicate that it's a continuation of what you started on the previous line