kevinmost
06/22/2016, 6:20 PMmapOf(
{ conditionA to (3 to 4) },
{ conditionB to (3 to 5) }
)
inline fun <K, V> mapOf(vararg addFunctions: () -> Pair<Boolean, Pair<K, V>>): Map<K, V> {
return mutableMapOf<K, V>().apply {
addFunctions.forEach {
val (shouldAdd, pair) = it()
if (shouldAdd) {
put(pair.first, pair.second)
}
}
}
}