ifEmpty for collections

This commit is contained in:
Andrey Breslav
2013-10-22 19:01:34 +04:00
parent cee4c0c29d
commit d0d77181e3
@@ -55,4 +55,6 @@ public fun <K, V: Any> Iterator<K>.keysToMapExceptNulls(value: (K) -> V?): Map<K
}
}
return map
}
}
public fun <T, C: Collection<T>> C.ifEmpty(body: () -> C): C = if (isEmpty()) body() else this