What is the rule in the Kotlin code style that ins...
# intellij
p
What is the rule in the Kotlin code style that insists on adding a blank line before
else
branch in
when
? It must be new or a bug. My
Blank Lines / Minimum blank lines
are all set to 0 except
Before declaration with comment
.
k
It only insists on a blank line if the previous case had multiple lines. It's not just the
else
case. Put a case
4 ->
before the
else
and you'll see the suggestion for a blank line before
4 ->
. See the guideline in https://kotlinlang.org/docs/coding-conventions.html#control-flow-statements: "In a
when
statement, if a branch is more than a single line, consider separating it from adjacent case blocks with a blank line"
p
got it! thanks.. that explains my case.. but it didn’t do it previously and there seems to be no way to turn it off
j
for multiline I prefer to use 3 -> { … }
👍 1