Skip to content

Instantly share code, notes, and snippets.

@husen-hn
Last active August 28, 2020 06:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save husen-hn/1923fcd531953458fb84fe10a2f79b1d to your computer and use it in GitHub Desktop.
Save husen-hn/1923fcd531953458fb84fe10a2f79b1d to your computer and use it in GitHub Desktop.
fun main() {
val immutableList = listOf(1,2,3,4,5,6,7) //(1)
println("Immutable List $immutableList")
val mutableList = immutableList.toMutableList() //(2)
println("Mutable List $mutableList")
mutableList.add(8) //(3)
println("Mutable List after add $mutableList")
println("Mutable List after add $immutableList")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment