isEmpty
Returns true
if this char sequence is empty (contains no characters).
Since Kotlin
1.1Samples
Returns true
if this char sequence is empty (contains no characters).
Returns true
if this char sequence is empty (contains no characters).
import java.util.Locale import kotlin.test.* fun main() { //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 }
xxxxxxxxxx
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)
Returns true
if this char sequence is empty (contains no characters).
import java.util.Locale import kotlin.test.* fun main() { //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 }
xxxxxxxxxx
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)
Thanks for your feedback!