v79
12/15/2021, 9:23 PMApple extends class Fruit, how can I create a map like mapOf<String,KClass<Fruit>>("apple" to Apple) ?ephemient
12/15/2021, 9:24 PMMap<String, KClass<out Fruit>>
as KClass<T> is invariantv79
12/15/2021, 9:29 PMv79
12/15/2021, 9:38 PMsuspend inline fun <reified T : Fruit> eat(), how do I call something like
val food = mapOf<String, KClass<Fruit>>("apple" to Apple)
val apple = food["apple"]
eat<apple> // this bit I struggle!ephemient
12/15/2021, 9:46 PM<reified>ephemient
12/15/2021, 9:47 PMfun <T : Fruit> eat(fruitClass: KClass<T>) would be callable, of coursev79
12/15/2021, 9:48 PMwhen(food) {
"org.me.apple" -> { eat<Apple>() }
"org.me.pear" -> { eat<Pear>() }
}v79
12/15/2021, 9:48 PMeat().Ayfri
12/16/2021, 5:28 PMinline to be able to get the type