This page is not yet available in Spanish. We are working on its translation.
If you have any questions or feedback about our current translation project, feel free to reach out to us!

Metadata

ID: kotlin-code-style/no-line-break-before-assignment

Language: Kotlin

Severity: Notice

Category: Code Style

Description

Keeping the assignment operator on the same line as the value being assigned improves understandability of code.

Non-Compliant Code Examples

val concurrency // The number of coroutines to use
    = 6

fun sum(a: Int, b: Int): Int
    =      a + b

fun countFor(jobName: String?
= null): Int = 3

val (first, last)
    = getName()

class Router {
    val isEnabled get()
        = true
}

val generate: () -> String?
        // For now, just return null
        = { null }

Compliant Code Examples

val concurrency = // The number of coroutines to use
    6

fun sum(a: Int, b: Int): Int =
    a + b

fun countFor(jobName: String? =
null): Int = 3

val (first, last) =
    getName()

class Router {
    val isEnabled get() =
        true
}

val generate: () -> String? =
        // For now, just return null
        { null }

fun sum(a: Int, b: Int): Int = a + b
https://static.datadoghq.com/static/images/logos/github_avatar.svg https://static.datadoghq.com/static/images/logos/vscode_avatar.svg jetbrains

Integraciones sin problemas. Prueba Datadog Code Security

PREVIEWING: guillaume.barrier/ERRORT-5095-general-doc-update