Someone happened to ask the same thing yesterday :...
# getting-started
k
Someone happened to ask the same thing yesterday simple smile
s
And i thought i got it but got it confused. Usually when i call a function dealing with generic type, i would be providing a specific parameter at call site, so in what cases would one pass a generic parameter?
k
Synthetic example:
Copy code
inline fun <reified T> foo() = println(T::class)
fun <T> bar() = foo<T>() //oops
👍 1
But this can often come up if you're in a class with a type parameter and want to use that.
s
Ah, got it
Thanks
Is there a better way to declare all reified all types (to force specific type parameter usage at call site) or is this the only way?
Copy code
inline fun <reified T, reified R> foo()
k
No, it's not that bad is it?
s
I meant like a single usage of reified applied instead of repeating it
k
Yeah I get is now, my bad. But no, there's no shorter way.
s
Got it