Is there an extension function on Collection that ...
# stdlib
m
Is there an extension function on Collection that accepts a MutableList and simply adds all its own items to it (i.e. like addAll() in reverse). At the moment I have to do this:
Copy code
.also {
    targetList.addAll(it)
}
p
Maybe something like this?
Copy code
val mutableList = mutableListOf(1, 2)
listOf(3, 4).mapTo(mutableList) { it }
s
Or
filterTo
p
Actually you can write:
Copy code
val mutableList = mutableListOf(1, 2)
listOf(3, 4).toCollection(mutableList)
👍 3
m
Perfect, thanks!