APXEOLOG
11/05/2018, 1:22 PMT
from the klass
?
fun <T> getProperty(klass: KClass<*>): T? {
return properties.find { it::class == klass } as T?
}
Right now it's working as entity.getProperty<String>(String::class)
and i want entity.getProperty(String::class)
nestserau
11/05/2018, 1:25 PMAPXEOLOG
11/05/2018, 1:26 PMdiesieben07
11/05/2018, 1:33 PMfun <T : Any> getProperty(klass: KClass<T>)
diesieben07
11/05/2018, 1:33 PMinline fun <reified T : Any> getProperty()
, then you can just do T::class
inside the function.APXEOLOG
11/05/2018, 1:34 PM<T : Any>
in generics docsnestserau
11/05/2018, 1:34 PMT::class
work despite type erasure?APXEOLOG
11/05/2018, 1:35 PMT::class
works with reified inline funcAPXEOLOG
11/05/2018, 1:35 PMnestserau
11/05/2018, 1:37 PMAPXEOLOG
11/05/2018, 1:37 PMspand
11/05/2018, 1:41 PMKClass
as a parameter and an inline function that calls that