Twidere-App-Android-Twitter.../twidere/src/main/kotlin/org/mariotaku/ktextension/ArrayExtensions.kt

24 lines
476 B
Kotlin
Raw Normal View History

2017-01-12 17:26:44 +01:00
package org.mariotaku.ktextension
/**
* Created by mariotaku on 2017/1/12.
*/
fun Array<*>?.isNotNullOrEmpty(): Boolean {
return this != null && this.isNotEmpty()
}
fun Array<*>?.isNullOrEmpty(): Boolean {
return this == null || this.isEmpty()
}
2017-02-10 16:38:59 +01:00
fun <T : Any> Array<T>.toNulls(): Array<T?> {
@Suppress("UNCHECKED_CAST")
return this as Array<T?>
2017-02-10 19:01:31 +01:00
}
fun <T : Any> Array<T>.toStringArray(): Array<String> {
return Array(size) { this[it].toString() }
}