https://kotlinlang.org logo
#getting-started
Title
# getting-started
g

Gavin Ray

03/19/2022, 7:21 PM
Would anyone be willing to explain to me what is happening in this image? I am having trouble understanding the type signature (never seen one like this before) and why it won't accept the value as a valid type
Copy code
and((MutableCollection<out Condition!>..Collection<Condition!>?))
I think this means "A type with a lower-bounds of
MutableCollection<out Condition!>
and an upper-bounds of `Collection<Condition!>?`"
But if that is true, then explicitly casting to either of those should have made it work, which it doesn't (as you see in the image) 🤔 😕
c

Carlos Ballesteros (InVideo)

03/19/2022, 9:14 PM
have you tried,
val x: MutableCollection<Condition>
?
p

phldavies

03/19/2022, 9:36 PM
Or
return add(*conds.toTypedArray())
g

Gavin Ray

03/20/2022, 3:34 PM
casting to varargs and typed array does work, but just confused why trying to return a
Collection
or
MutableCollection
doesn't
2 Views