Kotlin HashMap ifEmpty()
Syntax & Examples
Syntax of HashMap.ifEmpty()
The syntax of HashMap.ifEmpty() extension function is:
fun <M, R> M.ifEmpty( defaultValue: () -> R ): R where M : Map<*, *>, M : R
This ifEmpty() extension function of HashMap returns this map if it's not empty or the result of calling defaultValue function if the map is empty.