component2

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

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
(source)

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
(source)

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
}