kevinmost
09/14/2017, 5:17 PMtakeIf
internally. We just do it so frequently on a few types that it makes sense to make it look a little cleaner:
fun <T : CharSequence> T?.takeIfNotEmpty(): T? = this?.takeIf(CharSequence::isNotEmpty)
fun <T : Collection<*>> T?.takeIfNotEmpty(): T? = this?.takeIf(Collection<*>::isNotEmpty)
fun <T : Map<*, *>> T?.takeIfNotEmpty(): T? = this?.takeIf(Map<*, *>::isNotEmpty)