String utility methods

In the world of Java, we know due to null checks how many times we used to check nulls and an empty string as well. Kotlin is aware of this pain point and the stereotype code.kotlin.text package has many such useful functions.

 true is returned if this character sequence is empty (contains no characters):

    fun CharSequence.isEmpty(): Boolean

true is returned if this character sequence is not empty and contains some characters except whitespace characters:

    fun CharSequence.isNotBlank(): Boolean

 true is returned if this character sequence is not empty:

    fun CharSequence.isNotEmpty(): Boolean

 true is returned if this nullable character sequence is either null or empty or consists solely of whitespace characters:

 fun ...

Get Kotlin Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.