Hey folks, I want to do something like the followi...
# getting-started
j
Hey folks, I want to do something like the following
Copy code
val components: List<Component> = BuilderClass(...some stuff...).into(Component)
I.e. you use the 
into
 function to take any Class and return a list of that class Something like
Copy code
Class BuilderClass(...) {

  fun into(klass: KClass<Any>): List<what_goes_here?> {
     ...
Anyone know if this is possible?
p
fun <T : Any> into(klass: KClass<T>): List<T> {
?
the more Kotlin idiomatic way is
inline fun <reified T : Any> into(): List<T> {
, which would be called something like
into<Component>()
j
I need to introspect the instance inside
into()
in order to map a returned sql result set onto properties, so I’m guessing I’ll need the class as an argument in the func?
This is pretty cool though, thanks
But will mean I’ve got the rather unweildy syntax of
Copy code
BuilderClass(...).into<Component>(Component::class)
t
If you go with the
reified
approach from above, you don't need the explicit class parameter. You can just use
T::class
in your function body since the type is no longer erased.
☝️ 2
j
Oh, wow. That looks excited. I need to read about
reified
then. Thank you