given that `plus` has a single element overload, w...
# announcements
n
given that
plus
has a single element overload, what's the reason for plusElement existing?
n
might be the difference of Collection and MutableCollection receiver? I'd have to see the signatures
I think you can say
mutableList += element
and
list += element
and they mean different things
👆 1
n
@nanodeath
plusElement
has no relationship at all to +=
that's
plusAssign
yes,
+=
looks for plusAssign, if it doesn't find it, and the LHF is
var
and not
val
, it will try to expand to
list = list + element
->
list = list.plus(element)
plusElement isn't involved
n
okay well pretend I said
+
, still holds
n
nope, it doesn't
n
oh re: that YouTrack, it's lists-of-lists are a mess 😄
n
yeah
it's the List of Lists. I haven't read it in detail but I'm guessing that it ends up giving you a
List<Any>
or something like that 😞
hmm maybe not. At any rate, the answer is definitely there
@ilya.gorbunov thanks!
t
I looked into it again and yes, it's it's the list of lists. Collection<T>.plus has an overload that allows to add multiple values from another collection. This is resolved when trying to add a list to a list of lists, resulting in an implicit cast to List<Any>. plusElement can be used to avoid that behaviour and add the list as an element.
n
Yeah, I read the issue. It's kind of nasty that the deduction works that way