component1

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

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.


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

Returns 1st element from the list.

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


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

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.

Since Kotlin

1.3

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

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
}