How to convert vararg to list?
The vararg param needs to be spread with the spread *
operator.
fun insertMissingEntities(vararg entities: Entity) {
val list = listOf(*entities)
passMissingEntities(list)
}
You can use the extension function .asList()
, which does no added copying (unlike listOf
with the spread operator).
fun insertMissingEntities(vararg entities: Entity) {
passMissingEntities(entities.asList())
}