Why the latest ktlint formats when clauses like th...
# ktlint
n
Why the latest ktlint formats when clauses like this? How do I fix this?
Copy code
SupportedType.Knockout,
SupportedType.Factor,
-> LeverageType.Long
p
When trailing comma’s are enabled the nthis is the way how it should be formatted. A trailing comma like below would not make sense:
Copy code
when {
    SupportedType.Knockout,
    SupportedType.Factor, -> LeverageType.Long
your alternative would be:
Copy code
when {
    SupportedType.Knockout, SupportedType.Factor -> LeverageType.Long
but as soon as the when condition contains a newline than the arrow will be wrapped to a separate line.
n
Thanks for the answer. Does this really make sense for my case? I mean trailing comma could’ve been disabled for
when
clause?
p
Depends on your settings. It is a valid place for a trailing comma.