ru.inforion.lab403.common.extensions.collections.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kotlin-extensions Show documentation
Show all versions of kotlin-extensions Show documentation
Kotlin extension methods and function for different Java libraries
@file:Suppress("NOTHING_TO_INLINE")
package ru.inforion.lab403.common.extensions
inline fun Iterable.forEachNotNull(block: (T) -> Unit) = forEach {
if (it != null) block(it)
}
inline fun Array.forEachNotNull(block: (T) -> Unit) = forEach {
if (it != null) block(it)
}
inline fun collect(count: Int, item: (Int) -> T) = (0 until count).map(item)
inline fun collect(count: Int) = (0 until count).toList()