Quick question: why do we need to specify which ty...
# announcements
r
Quick question: why do we need to specify which types are reified in an inline function? As it's inlined, aren't all types basically automatically reified?
s
Here the Person object is kept track in a generic Java Object type
Copy code
data class Person( val age : Int )

fun main(args: Array<String>) {
    "sample".printParameters( "string", Person(22 ) )
}

private inline fun <reified T, R> String.printParameters( value1 : T, value2 : R ) {
    println( "$this $value1 $value2" )

    when( this ) {
        is T -> println( "Object is of type ${T::class.java}" )
        else -> println( "Unknown type")
    }
}