Home > Software design >  multiple reified parameter types in kotlin
multiple reified parameter types in kotlin

Time:11-11

is it possible to have multiple reified type parameters in Kotlin. I can do something like:

inline fun <reified T> func(column: String): T {
   return when(column) {
      ....
   } 
}

Can this be extended to something like:

inline fun <reified T, reified U> func(column: String): Pair(T, U) {
}

CodePudding user response:

Multiple reified parameters are supported in a regular way. if your problem is that your code does not compile then this is because you wrote Pair(T, U) instead of Pair<T, U>:

inline fun <reified T, reified U> func(column: String): Pair<T, U>
  • Related