kotlin.collections.getOrElse

getOrElse

inline fun <K, V> Map<K, V>.getOrElse(
    key: K, 
    defaultValue: () -> V
): V

Returns the value for the given key, or the result of the defaultValue function if there was no entry for the given key.

import kotlin.test.*
import java.util.*
import kotlin.comparis