component2

inline operator fun <T> Array<out T>.component2(): T
inline operator fun ByteArray.component2(): Byte
inline operator fun ShortArray.component2(): Short
inline operator fun IntArray.component2(): Int
inline operator fun LongArray.component2(): Long
inline operator fun FloatArray.component2(): Float
inline operator fun DoubleArray.component2(): Double
inline operator fun BooleanArray.component2(): Boolean
inline operator fun CharArray.component2(): Char

Returns 2nd element from the array.

If the size of this array is less than 2, throws an IndexOutOfBoundsException except in Kotlin/JS where the behavior is unspecified.


inline operator fun <T> List<T>.component2(): T

Returns 2nd element from the list.

Throws an IndexOutOfBoundsException if the size of this list is less than 2.


inline operator fun UIntArray.component2(): UInt
inline operator fun ULongArray.component2(): ULong
inline operator fun UByteArray.component2(): UByte
inline operator fun UShortArray.component2(): UShort

Returns 2nd element from the array.

If the size of this array is less than 2, throws an IndexOutOfBoundsException except in Kotlin/JS where the behavior is unspecified.

Since Kotlin

1.3

inline operator fun <K, V> Map.Entry<K, V>.component2(): V

Returns the value component of the map entry.

This method allows to use destructuring declarations when working with maps, for example:

for ((key, value) in map) {
// do something with the key and the value
}