Is there a way to get a use of `MutableCollection:...
# stdlib
p
Is there a way to get a use of
MutableCollection::plusAssign(Iterable)
to compile without having assignment operators ambiguity error? Here an example that does not compile:
Copy code
val list = listOf(1, 2, 3)
	var mutableList = mutableListOf(4, 5, 6)
	mutableList += list
g
Only if you replace
var
with
val
If you need
var
there, than use addAll instead:
mutableList.addAll(list)
p
oh, yes I need var in my case, and now I understand what's up; thanks!
however, maybe it'd be nice if
plusAssign
had preference over
plus
+
assign
to avoid this odd situation
g
mutableList += 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