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

14 lines
396 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
2021-05-11 08:12:43 +02:00
fun ByteArray?.notEmpty(): ByteArray? =
if (this?.isNotEmpty() == true) this else null