tc39 / proposal-string-dedent

TC39 Proposal to remove common leading indentation from multiline template strings
https://tc39.es/proposal-string-dedent/
MIT License
625 stars 17 forks source link

Update the Kotlin documentation #79

Closed mahozad closed 1 year ago

mahozad commented 1 year ago

Common leading whitespace in Kotlin multiline (raw) strings is not automatically removed. If the programmer wants them removed, they should either call .trimIndent() or prefix every line of their string with a common prefix (the default is |) and call .trimMargin().

Example using .trimIndent():

val string = """
    Hello
    World
""".trimIndent()

Examples using .trimMargin():

val string1 = """
    |Hello
    |World
""".trimMargin()

val string2 = """
    > Hello
    > World
""".trimMargin("> ")