Google is committed to advancing racial equity for Black communities. See how.

Pair

open class Pair<F : Any!, S : Any!>
kotlin.Any
   ↳ androidx.core.util.Pair

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
<init>(first: F, second: S)

Constructor for a Pair.

Public methods
open static Pair<A, B>
create(a: A, b: B)

Convenience method for creating an appropriately typed pair.

open Boolean
equals(other: Any?)

Checks the two objects for equality by delegating to their respective Object#equals(Object) methods.

open Int

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

open String

Extension functions
From androidx.core.util
operator F
Pair<F, S>.component1()

Returns the first component of the pair.

operator S
Pair<F, S>.component2()

Returns the second component of the pair.

Pair<F, S>

Returns this AndroidX Pair as a Kotlin Pair.

Properties
F

S

Public constructors

<init>

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 methods

create

@NonNull open static fun <A : Any!, B : Any!> 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
Return
Pair<A, B> a Pair that is templatized with the types of a and b

equals

open fun equals(other: Any?): Boolean

Checks the two objects for equality by delegating to their respective Object#equals(Object) methods.

Parameters
o the Pair to which this one is to be checked for equality
Return
Boolean true if the underlying objects of the Pair are both considered equal

hashCode

open fun hashCode(): Int

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

Return
Int a hashcode of the Pair

toString

@NonNull open fun toString(): String

Properties

first

val first: F

second

val second: S