I tried asking in the reflect channel and couldn’t...
# announcements
m
I tried asking in the reflect channel and couldn’t get a response. It might be a dumb question but I figured I would ask here. Which of these approaches would be the most performant way of finding a constructor of a generic that takes an argument that is a subclass of type ‘Item’
Copy code
T::class.constructors.find {
       it.parameters.size == 1 &&
       it.parameters[0].type.isSubtypeOf(Item::class.createType())
}
    
T::class.constructors.find {
        it.parameters.size == 1 &&
        it.parameters[0].type.jvmErasure.isSubclassOf(Item::class)
}
i
gorgamore: At the risk of stating the obvious, it might be easier just to benchmark it 🙂
m
@Ian I think you're right. Sometimes it's best to just do the obvious lol. Thx