-
Notifications
You must be signed in to change notification settings - Fork 14
How to break line when cast ("as") or colon (":") is present #45
Comments
Variant 1 val field = someFunction(
valueA,
valueB
) as SpecificType
class ClassA(
paramA: String
paramB: String
) : ClassB() |
Variant 2 val field = someFunction(
valueA,
valueB) as SpecificType
class ClassA(
paramA: String
paramB: String) : ClassB() |
Variant 3 val field = someFunction(valueA, valueB) as
SpecificType
class ClassA(paramA: String, paramB: String) :
ClassB() |
Variant 4 val field = someFunction(valueA, valueB)
as SpecificType
class ClassA(paramA: String, paramB: String)
: ClassB() |
I actually prefer variants 1 and 4 over the others. My reasoning being that I see It comes down to readability, 3 splits coherent terms in the middle, and 2 puts them on the same line with the last part of the expression before it without any good reason to do so, while the rest of that expression is otherwise nicely chunked up, which again makes for poor readability in my opinion. |
I would discourage variant 4 for classes though, as those should always either be true one-liners or have their primary constructor paramaters on individual lines, that |
For class header formatting, see #2. For |
I would say no difference. Do you have recommendation for operators? |
How to to properly break line cast (
as
,as?
) or colon (:
) is present and it doesn't fit in one line? I think variants 1 and 2 are good, 3 is acceptable, 4 should be forbidden.The text was updated successfully, but these errors were encountered: