SubwayTooter-Android-App/app/src/main/java/jp/juggler/util/CollectionUtils.kt

11 lines
301 B
Kotlin
Raw Normal View History

2019-12-22 14:06:03 +01:00
package jp.juggler.util
// same as x?.let{ dst.add(it) }
fun <T> T.addTo(dst: ArrayList<T>) = dst.add(this)
2020-12-07 13:23:14 +01:00
fun <E : List<*>> E?.notEmpty(): E? =
if (this?.isNotEmpty() == true) this else null
fun <E : Map<*, *>> E?.notEmpty(): E? =
if (this?.isNotEmpty() == true) this else null