isn't possible to implement the spread operator in...
# announcements
e
isn't possible to implement the spread operator in a class, is it?
🚫 1
a
what are you trying to do?
d
I think they are asking to make
*
an
operator fun
, so you can enable it on instances of your own classes and not just arrays. Which I think is a good idea, it would allow to pass any collection to
vararg
.
e
Exactly
Copy code
val color = Vec4()

val vertexData = floatArrayOf(*color)
d
Interestingly there seems to be
kotlin.jvm.internal.SpreadBuilder
already, which supports spreading
Collection
,
Iterable
and
Iterator
, but the compiler does not let you.
e