mariodroid
02/16/2018, 5:11 AMdata class Foo(var bar: String, var listFoos: MutableList<String>)
val foos = mutableListOf("one", "due", "three")
val pair = Pair(Foo("bar", foos), mutableListOf("ignore", "me"))
val pairCopy = pair.copy()
info { "Pair " + pair.second + "and :" + pair.first.listFoos }
info { "Pair Copy" + pairCopy.second + "and :" + pairCopy.first.listFoos }
pairCopy.second.clear()
pairCopy.first.listFoos.clear()
pairCopy.first.bar = "SUCKIT"
info { "Pair Copy Cleared " + pairCopy.second.toString() + "and :" + pairCopy.first.listFoos.toString() }
info { "Pair: " + pair.second + "and :" + pair.first.listFoos }
info { "Pair Bar property: " + pair.first.bar }
no matter what I do the list on the first pair is cleared, I supposed that the copy method reallocate the pair object, which does work just for no list type
what to do ?540grunkspin
02/16/2018, 9:46 AMmariodroid
02/19/2018, 4:44 AM