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

用法:

fun CharSequence.isNotEmpty(): Boolean

如果此字符序列不为空,则返回 true

例子:

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

fun main(args: Array<String>) {
//sampleStart
fun markdownLink(title: String, url: String) =
    if (title.isNotEmpty()) "[$title]($url)" else 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)