is there a way to resolve an ambiguous += to a list?
cliOptions += CliOption()
clioptions is a java List
Copy code
Assignment operators ambiguity. All these functions match.
public operator fun <T> Collection<CliOption!>.plus(element: CliOption!): List<CliOption!> defined in kotlin.collections
public inline operator fun <T> MutableCollection<in CliOption>.plusAssign(element: CliOption): Unit defined in kotlin.collections
j
Joffrey
08/12/2022, 5:18 PM
You could do
cliOptions.add(CliOption())
or
cliOptions = cliOptions + CliOption()
depending on the one you want
e
ephemient
08/12/2022, 5:40 PM
not always but often
var : MutableList
is a poor design choice anyway
plus1 1
s
sreich
08/12/2022, 5:47 PM
@Joffrey why do i have to do
= +
? this doesn't really answer why += doesn't work, and why i have to explicitly call assignPlus()
sreich
08/12/2022, 5:47 PM
which sucks because they're all noisier than just doing +=