Pair
Represents a generic pair of two values.
There is no meaning attached to values in this class, it can be used for any purpose. Pair exhibits value semantics, i.e. two pairs are equal if both components are equal.
An example of decomposing it into values:
Since Kotlin
1.1Parameters
A
type of the first value.
B
type of the second value.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val (a, b) = Pair(1, "x")
println(a) // 1
println(b) // x
//sampleEnd
}
Represents a generic pair of two values.
There is no meaning attached to values in this class, it can be used for any purpose. Pair exhibits value semantics, i.e. two pairs are equal if both components are equal.
An example of decomposing it into values:
Since Kotlin
1.0Parameters
A
type of the first value.
B
type of the second value.
Samples
import kotlin.test.*
fun main() {
//sampleStart
val (a, b) = Pair(1, "x")
println(a) // 1
println(b) // x
//sampleEnd
}