first

Common
JVM
JS
Native
1.0
fun <T> Array<out T>.first(): T
fun ByteArray.first(): Byte
fun ShortArray.first(): Short
fun IntArray.first(): Int
fun LongArray.first(): Long
fun FloatArray.first(): Float
fun DoubleArray.first(): Double
fun BooleanArray.first(): Boolean
fun CharArray.first(): Char

Returns first element.

Exceptions

NoSuchElementException - if the array is empty.

Common
JVM
JS
Native
1.0
inline fun <T> Array<out T>.first(
    predicate: (T) -> Boolean
): T
inline fun ByteArray.first(
    predicate: (Byte) -> Boolean
): Byte
inline fun ShortArray.first(
    predicate: (Short) -> Boolean
): Short
inline fun IntArray.first(predicate: (Int) -> Boolean): Int
inline fun LongArray.first(
    predicate: (Long) -> Boolean
): Long
inline fun FloatArray.first(
    predicate: (Float) -> Boolean
): Float
inline fun DoubleArray.first(
    predicate: (Double) -> Boolean
): Double
inline fun BooleanArray.first(
    predicate: (Boolean) -> Boolean
): Boolean
inline fun CharArray.first(
    predicate: (Char) -> Boolean
): Char
inline fun <T> Iterable<T>.first(
    predicate: (T) -> Boolean
): T

Returns the first element matching the given predicate.

Exceptions

NoSuchElementException - if no such element is found.

Common
JVM
JS
Native
1.0
fun <T> Iterable<T>.first(): T

Returns first element.

Exceptions

NoSuchElementException - if the collection is empty.

Common
JVM
JS
Native
1.0
fun <T> List<T>.first(): T

Returns first element.

Exceptions

NoSuchElementException - if the list is empty.