Pair

Added in 1.1.0

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
equals(o: Any!)

Checks the two objects for equality by delegating to their respective equals methods.

Int

Compute a hash code using the hash codes of the underlying objects

String

Public properties

F!
S!

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 AndroidX Pair as a Kotlin Pair.

Public constructors

Pair

Added in 1.1.0
Pair(first: F!, second: S!)

Constructor for a Pair.

Parameters
first: F!

the first object in the Pair

second: S!

the second object in the pair

Public functions

create

Added in 1.1.0
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.

Parameters
o: Any!

the Pair to which this one is to be checked for equality

Returns
Boolean

true if the underlying objects of the Pair are both considered equal

hashCode

fun hashCode(): Int

Compute a hash code using the hash codes of the underlying objects

Returns
Int

a hashcode of the Pair

toString

fun toString(): String

Public properties

first

Added in 1.1.0
val first: F!

second

Added in 1.1.0
val second: S!

Extension functions

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

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

toKotlinPair

inline fun <F : Any?, S : Any?> Pair<F, S>.toKotlinPair(): Pair<F, S>

Returns this AndroidX Pair as a Kotlin Pair.