Pere Casafont
04/29/2019, 9:44 AMMutableCollection::plusAssign(Iterable)
to compile without having assignment operators ambiguity error? Here an example that does not compile:
val list = listOf(1, 2, 3)
var mutableList = mutableListOf(4, 5, 6)
mutableList += list
gildor
04/29/2019, 9:49 AMvar
with val
If you need var
there, than use addAll instead:
mutableList.addAll(list)
Pere Casafont
04/29/2019, 10:07 AMplusAssign
had preference over plus
+ assign
to avoid this odd situationgildor
04/29/2019, 10:13 AMmutableList += list
is acutally reassign mutableList, but (mutableList + list) returns List, so type is not compatible, so it’s not clear how you can solve it