trimIndent所在位置是kotlin.text.trimIndent,其相關用法介紹如下。

用法:

fun String.trimIndent(): String

檢測所有輸入行的公共最小縮進,將其從每一行中刪除,如果第一行和最後一行為空白(注意空白與空的區別),則還刪除它們。

請注意,空行不會影響檢測到的縮進級別。

如果存在沒有前導空白字符的非空行(根本沒有縮進),則公共縮進為 0,因此此函數不會更改縮進。

不保留原始行尾。

例子:

import java.util.Locale
import kotlin.test.*

fun main(args: Array<String>) {
//sampleStart
val withoutIndent =
        """
            ABC
            123
            456
        """.trimIndent()
println(withoutIndent) // ABC\n123\n456
//sampleEnd
}

輸出:

ABC
123
456

也可以看看

trimMargin

kotlin.text.isBlank