How would I go about implementing something like this:
Copy code
fun <R> convertTo(): R {
return convertImpl()
}
fun convertImpl(): Int {
// ...
}
fun convertImpl(): String {
// ...
}
Is there an easy way to do it or will I have to just use a when statement and make R reified and add a branch for each implemented type?
j
Joffrey
12/15/2021, 12:12 AM
If it were the other way around I guess polymorphism would be best, but since in your case the call site is supposed to decide the output type, you might want a