takeIfNotEmpty

fun <C : Collection<*>> C.takeIfNotEmpty(): C?

Returns this collection if it is not empty, or null otherwise.


fun <M : Map<*, *>> M.takeIfNotEmpty(): M?

Returns this map if it is not empty, or null otherwise.