component2

Common
JVM
JS
Native
1.0
operator fun <T> Array<out T>.component2(): T
operator fun ByteArray.component2(): Byte
operator fun ShortArray.component2(): Short
operator fun IntArray.component2(): Int
operator fun LongArray.component2(): Long
operator fun FloatArray.component2(): Float
operator fun DoubleArray.component2(): Double
operator fun BooleanArray.component2(): Boolean
operator fun CharArray.component2(): Char
@ExperimentalUnsignedTypes operator fun UIntArray.component2(): UInt
@ExperimentalUnsignedTypes operator fun ULongArray.component2(): ULong
@ExperimentalUnsignedTypes operator fun UByteArray.component2(): UByte
@ExperimentalUnsignedTypes 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.

Common
JVM
JS
Native
1.0
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.

Common
JVM
JS
Native
1.0
operator fun <K, V> 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
}