isEmpty所在位置是kotlin.text.isEmpty,其相关用法介绍如下。

用法:

fun CharSequence.isEmpty(): Boolean

如果此字符序列为空(不包含字符),则返回 true

例子:

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

fun main(args: Array<String>) {
//sampleStart
fun markdownLink(title: String, url: String) =
    if (title.isEmpty()) url else "[$title]($url)"

// plain link
println(markdownLink(title = "", url = "https://kotlinlang.org")) // https://kotlinlang.org

// link with custom title
println(markdownLink(title = "Kotlin Language", url = "https://kotlinlang.org")) // [Kotlin Language](https://kotlinlang.org)
//sampleEnd
}

输出:

https://kotlinlang.org
[Kotlin Language](https://kotlinlang.org)