Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
fun CharSequence?.isNullOrEmpty(): Boolean

Returns true if this nullable char sequence is either null or empty.

import kotlin.test.*

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

// plain link
println(markdownLink(title = null, 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)

© 2010–2019 JetBrains s.r.o.
Licensed under the Apache License, Version 2.0.