Is there any method in kotlin which replaces below two line into one. I know i can create a extension function but I'm eager to know if it already exist in kotlin. Something like listOfChecklist.clearAndAddAll()
.
listOfChecklist.clear()
listOfChecklist.addAll(newList)
This is what I'm doing now manually using an extension function. But I hope there is a better solution.
fun <E> MutableCollection<E>.clearAndAddAll(replace: MutableSet<E>) {
clear()
addAll(replace)
}