Skip to content

Trailing comma on when-case should be followed by newline. #376

@plobsing

Description

@plobsing

To be consistent with the handling of other constructs that support trailing commas. In particular the case of a trailing-comma followed by -> is also seen with lambdas where it does prompt the insertion of a newline.

val whenWithTrailingComma =
    when (someEnum) {
        A,
        B, -> caseBody() // Trailing comma does not prevent the elision of any newlines.
        else -> TODO("unhandled")
    }

val lambdaWithTrailingComma =
    { a, b, // Trailing comma leads to newline insertion.
        ->
        body()
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions