Home > Enterprise >  passing Kotlin Tuple to a Java function
passing Kotlin Tuple to a Java function

Time:11-17

I have a Kotlin function which returns a map like Map<String, Pair<String, String>>. I need to pass it to a java function and java does not seem to have a Pair data structure. What would be the best way to pass such a structure to the Java function?

CodePudding user response:

You can just use Pair (import kotlin.Pair;) , since that is compiled to a JVM class, this isn't any different from using any other kotlin class in java.

https://kotlinlang.org/docs/java-to-kotlin-interop.html

  • Related