On this page
maxBy
Platform and version requirements: JS (1.7), Native (1.7)
@JvmName("maxByOrThrow") inline fun <T, R : Comparable<R>> Array<out T>.maxBy(
selector: (T) -> R
): T
Platform and version requirements: JVM (1.0)
@DeprecatedSinceKotlin("1.4", "1.5", "1.6") inline fun <T, R : Comparable<R>> Array<out T>.maxBy(
selector: (T) -> R
): T? Deprecated: Use maxByOrNull instead.
Platform and version requirements: JS (1.7), Native (1.7)
@JvmName("maxByOrThrow") inline fun <R : Comparable<R>> ByteArray.maxBy(
selector: (Byte) -> R
): Byte
Platform and version requirements: JVM (1.0)
@DeprecatedSinceKotlin("1.4", "1.5", "1.6") inline fun <R : Comparable<R>> ByteArray.maxBy(
selector: (Byte) -> R
): Byte? Deprecated: Use maxByOrNull instead.
Platform and version requirements: JS (1.7), Native (1.7)
@JvmName("maxByOrThrow") inline fun <R : Comparable<R>> ShortArray.maxBy(
selector: (Short) -> R
): Short
Platform and version requirements: JVM (1.0)
@DeprecatedSinceKotlin("1.4", "1.5", "1.6") inline fun <R : Comparable<R>> ShortArray.maxBy(
selector: (Short) -> R
): Short? Deprecated: Use maxByOrNull instead.
Platform and version requirements: JS (1.7), Native (1.7)
@JvmName("maxByOrThrow") inline fun <R : Comparable<R>> IntArray.maxBy(
selector: (Int) -> R
): Int
Platform and version requirements: JVM (1.0)
@DeprecatedSinceKotlin("1.4", "1.5", "1.6") inline fun <R : Comparable<R>> IntArray.maxBy(
selector: (Int) -> R
): Int? Deprecated: Use maxByOrNull instead.
Platform and version requirements: JS (1.7), Native (1.7)
@JvmName("maxByOrThrow") inline fun <R : Comparable<R>> LongArray.maxBy(
selector: (Long) -> R
): Long
Platform and version requirements: JVM (1.0)
@DeprecatedSinceKotlin("1.4", "1.5", "1.6") inline fun <R : Comparable<R>> LongArray.maxBy(
selector: (Long) -> R
): Long? Deprecated: Use maxByOrNull instead.
Platform and version requirements: JS (1.7), Native (1.7)
@JvmName("maxByOrThrow") inline fun <R : Comparable<R>> FloatArray.maxBy(
selector: (Float) -> R
): Float
Platform and version requirements: JVM (1.0)
@DeprecatedSinceKotlin("1.4", "1.5", "1.6") inline fun <R : Comparable<R>> FloatArray.maxBy(
selector: (Float) -> R
): Float? Deprecated: Use maxByOrNull instead.
Platform and version requirements: JS (1.7), Native (1.7)
@JvmName("maxByOrThrow") inline fun <R : Comparable<R>> DoubleArray.maxBy(
selector: (Double) -> R
): Double
Platform and version requirements: JVM (1.0)
@DeprecatedSinceKotlin("1.4", "1.5", "1.6") inline fun <R : Comparable<R>> DoubleArray.maxBy(
selector: (Double) -> R
): Double? Deprecated: Use maxByOrNull instead.
Platform and version requirements: JS (1.7), Native (1.7)
@JvmName("maxByOrThrow") inline fun <R : Comparable<R>> BooleanArray.maxBy(
selector: (Boolean) -> R
): Boolean
Platform and version requirements: JVM (1.0)
@DeprecatedSinceKotlin("1.4", "1.5", "1.6") inline fun <R : Comparable<R>> BooleanArray.maxBy(
selector: (Boolean) -> R
): Boolean? Deprecated: Use maxByOrNull instead.
Platform and version requirements: JS (1.7), Native (1.7)
@JvmName("maxByOrThrow") inline fun <R : Comparable<R>> CharArray.maxBy(
selector: (Char) -> R
): Char
Platform and version requirements: JVM (1.0)
@DeprecatedSinceKotlin("1.4", "1.5", "1.6") inline fun <R : Comparable<R>> CharArray.maxBy(
selector: (Char) -> R
): Char? Deprecated: Use maxByOrNull instead.
Platform and version requirements: JS (1.7), Native (1.7)
@JvmName("maxByOrThrow-U") @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> UIntArray.maxBy(
selector: (UInt) -> R
): UInt
Platform and version requirements: JVM (1.3)
@DeprecatedSinceKotlin("1.4", "1.5", "1.6") @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> UIntArray.maxBy(
selector: (UInt) -> R
): UInt? Deprecated: Use maxByOrNull instead.
Platform and version requirements: JS (1.7), Native (1.7)
@JvmName("maxByOrThrow-U") @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> ULongArray.maxBy(
selector: (ULong) -> R
): ULong
Platform and version requirements: JVM (1.3)
@DeprecatedSinceKotlin("1.4", "1.5", "1.6") @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> ULongArray.maxBy(
selector: (ULong) -> R
): ULong? Deprecated: Use maxByOrNull instead.
Platform and version requirements: JS (1.7), Native (1.7)
@JvmName("maxByOrThrow-U") @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> UByteArray.maxBy(
selector: (UByte) -> R
): UByte
Platform and version requirements: JVM (1.3)
@DeprecatedSinceKotlin("1.4", "1.5", "1.6") @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> UByteArray.maxBy(
selector: (UByte) -> R
): UByte? Deprecated: Use maxByOrNull instead.
Platform and version requirements: JS (1.7), Native (1.7)
@JvmName("maxByOrThrow-U") @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> UShortArray.maxBy(
selector: (UShort) -> R
): UShort
Platform and version requirements: JVM (1.3)
@DeprecatedSinceKotlin("1.4", "1.5", "1.6") @ExperimentalUnsignedTypes inline fun <R : Comparable<R>> UShortArray.maxBy(
selector: (UShort) -> R
): UShort? Deprecated: Use maxByOrNull instead.
Returns the first element yielding the largest value of the given function.
fun main(args: Array<String>) {
//sampleStart
//Unresolved: samples.collections.Collections.Aggregates.maxBy
//sampleEnd
}
Exceptions
NoSuchElementException - if the array is empty.
Platform and version requirements: JS (1.7), Native (1.7)
@JvmName("maxByOrThrow") inline fun <T, R : Comparable<R>> Iterable<T>.maxBy(
selector: (T) -> R
): T
Platform and version requirements: JVM (1.0)
@DeprecatedSinceKotlin("1.4", "1.5", "1.6") inline fun <T, R : Comparable<R>> Iterable<T>.maxBy(
selector: (T) -> R
): T? Deprecated: Use maxByOrNull instead.
Returns the first element yielding the largest value of the given function.
fun main(args: Array<String>) {
//sampleStart
//Unresolved: samples.collections.Collections.Aggregates.maxBy
//sampleEnd
}
Exceptions
NoSuchElementException - if the collection is empty.
Platform and version requirements: JS (1.7), Native (1.7)
@JvmName("maxByOrThrow") inline fun <K, V, R : Comparable<R>> Map<out K, V>.maxBy(
selector: (Entry<K, V>) -> R
): Entry<K, V>
Platform and version requirements: JVM (1.0)
@DeprecatedSinceKotlin("1.4", "1.5", "1.6") inline fun <K, V, R : Comparable<R>> Map<out K, V>.maxBy(
selector: (Entry<K, V>) -> R
): Entry<K, V>? Deprecated: Use maxByOrNull instead.
Returns the first entry yielding the largest value of the given function.
fun main(args: Array<String>) {
//sampleStart
//Unresolved: samples.collections.Collections.Aggregates.maxBy
//sampleEnd
}
Exceptions
NoSuchElementException - if the map is empty.
© 2010–2023 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/max-by.html