import scala.collection.mutable.ArrayBuffer
@main def main(): Unit =
val source = ArrayBuffer(1, 2, 3)
// toList copies the contents into an immutable List
val snapshot = source.toList
source += 4
// the snapshot is unaffected by later mutation
println(s"$snapshot ${source.toList}")snapshot into an immutable value