commonMain.com.paoapps.fifi.utils.CollectionUtils.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fifi-common Show documentation
Show all versions of fifi-common Show documentation
Kotlin Multiplatform Mobile framework for optimal code sharing between iOS and Android.
The newest version!
package com.paoapps.fifi.utils
fun Iterable.insertInBetween(item: T): List {
val result = mutableListOf()
forEach { element ->
if (result.isNotEmpty()) {
result.add(item)
}
result.add(element)
}
return result
}
fun Set.toggle(item: T): Set = if (contains(item)) minus(item) else plus(item)