https://kotlinlang.org logo
Title
e

elect

03/07/2018, 10:24 AM
isn't possible to implement the spread operator in a class, is it?
🇳🇴 1
a

Andreas Sinz

03/07/2018, 10:33 AM
what are you trying to do?
d

diesieben07

03/07/2018, 10:49 AM
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

elect

03/07/2018, 10:53 AM
Exactly
val color = Vec4()

val vertexData = floatArrayOf(*color)
d

diesieben07

03/07/2018, 10:56 AM
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

elect

03/07/2018, 10:58 AM