Pair
class Pair<F, S>
Container to ease passing around a tuple of two objects. This object provides a sensible implementation of equals(), returning true if equals() is true on each of the contained objects.
Summary
Public constructors |
|---|
Pair(first: F!, second: S!)Constructor for a Pair. |
Public functions |
|
|---|---|
java-static Pair<A!, B!> |
<A, B> create(a: A!, b: B!)Convenience method for creating an appropriately typed pair. |
Boolean |
Checks the two objects for equality by delegating to their respective |
Int |
hashCode()Compute a hash code using the hash codes of the underlying objects |
String |
toString() |
Extension functions |
|
|---|---|
inline operator F |
<F : Any?, S : Any?> Pair<F, S>.component1()Returns the first component of the pair. |
inline operator S |
<F : Any?, S : Any?> Pair<F, S>.component2()Returns the second component of the pair. |
inline Pair<F, S> |
<F : Any?, S : Any?> Pair<F, S>.toKotlinPair()Returns this |
Public constructors
Public functions
create
java-static fun <A, B> create(a: A!, b: B!): Pair<A!, B!>
Convenience method for creating an appropriately typed pair.
| Parameters | |
|---|---|
a: A! |
the first object in the Pair |
b: B! |
the second object in the pair |
| Returns | |
|---|---|
Pair<A!, B!> |
a Pair that is templatized with the types of a and b |
equals
fun equals(o: Any!): Boolean
Checks the two objects for equality by delegating to their respective equals methods.
| Returns | |
|---|---|
Boolean |
true if the underlying objects of the Pair are both considered equal |
Extension functions
Pair.component1
inline operator fun <F : Any?, S : Any?> Pair<F, S>.component1(): F
Returns the first component of the pair.
This method allows to use destructuring declarations when working with pairs, for example:
val (first, second) = myPair
Pair.component2
inline operator fun <F : Any?, S : Any?> Pair<F, S>.component2(): S
Returns the second component of the pair.
This method allows to use destructuring declarations when working with pairs, for example:
val (first, second) = myPair
Pair.toKotlinPair
inline fun <F : Any?, S : Any?> Pair<F, S>.toKotlinPair(): Pair<F, S>
Returns this AndroidX as a PairKotlin .Pair