Values & References10 / 15
Up next

An independent copy

fun main() {
    val original = mutableListOf(1, 2, 3)
    // a separate list; changes do not leak back
    val copy = original.toMutableList()
    copy.add(4)
    println("$original $copy")
}
What you're solving

toMutableList clones the data