component1

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

Returns 1st element from the array.

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

Common
JVM
JS
Native
1.0
operator fun <T> List<T>.component1(): T
(source)

Returns 1st element from the list.

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

Common
JVM
JS
Native
1.0
operator fun <K, V> Entry<K, V>.component1(): K
(source)

Returns the key 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
}