Is there a map merge function ala `fun <K, V&gt...
# stdlib
s
Is there a map merge function ala
fun <K, V> Iterable<Map<K, V>>.merge(): Map<K, V>
that I am missing ?
j
fold with plus
1
e
or
Copy code
fun <K, V> Iterable<Map<K, V>>.merge(): Map<K, V> = buildMap {
    for (map in this@merge) putAll(map)
}
which won't have the O(N^2) behavior that
fold(::plus)
will
👌 2
alternatively,
Copy code
.asSequence().flatMap { it.entries }.associateBy({ it.key }, { it.value })
would also work
s
Thanks !