We have an inline function printType() that takes a reified type parameter T. The function simply prints the name of the type at runtime using the simpleName property of the KClass instance.
In the main() function, we call printType() with three different type arguments (String, Int, and Double).
Arrange the code in the correct order. The first will be the function printType.
Inline functions and reified types in Kotlin
Mixed up code
Report a typo
Reorder lines using drag or arrows. Adjust indentation with left buttons
printType<Int>()
}
printType<Double>()
inline fun <reified T> printType() {
fun main() {
}
println(T::class.simpleName)
printType<String>()
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.