max

@JvmName(name = "maxOrThrow")
fun Array<out Double>.max(): Double(source)
@JvmName(name = "maxOrThrow")
fun Array<out Float>.max(): Float(source)
@JvmName(name = "maxOrThrow")
fun FloatArray.max(): Float(source)
@JvmName(name = "maxOrThrow")
fun DoubleArray.max(): Double(source)

Returns the largest element.

If any of elements is NaN returns NaN.

Since Kotlin

1.7

Throws

if the array is empty.


@JvmName(name = "maxOrThrow")
fun <T : Comparable<T>> Array<out T>.max(): T(source)
@JvmName(name = "maxOrThrow")
fun ByteArray.max(): Byte(source)
@JvmName(name = "maxOrThrow")
fun ShortArray.max(): Short(source)
@JvmName(name = "maxOrThrow")
fun IntArray.max(): Int(source)
@JvmName(name = "maxOrThrow")
fun LongArray.max(): Long(source)
@JvmName(name = "maxOrThrow")
fun CharArray.max(): Char(source)
@JvmName(name = "maxOrThrow-U")
fun UIntArray.max(): UInt(source)

Returns the largest element.

Since Kotlin

1.7

Throws

if the array is empty.


@JvmName(name = "maxOrThrow")
fun Iterable<Double>.max(): Double(source)
@JvmName(name = "maxOrThrow")
fun Iterable<Float>.max(): Float(source)

Returns the largest element.

If any of elements is NaN returns NaN.

Since Kotlin

1.7

Throws

if the collection is empty.


@JvmName(name = "maxOrThrow")
fun <T : Comparable<T>> Iterable<T>.max(): T(source)

Returns the largest element.

Since Kotlin

1.7

Throws

if the collection is empty.

Deprecated

Warning since 1.4

Error since 1.5

Hidden since 1.6

Use maxOrNull instead.

Replace with

this.maxOrNull()

Since Kotlin

1.1

fun <T : Comparable<T>> Array<out T>.max(): T?(source)
fun <T : Comparable<T>> Iterable<T>.max(): T?(source)

Deprecated

Warning since 1.4

Error since 1.5

Hidden since 1.6

Use maxOrNull instead.

Replace with

this.maxOrNull()

Since Kotlin

1.0

Deprecated

Warning since 1.4

Error since 1.5

Hidden since 1.6

Use maxOrNull instead.

Replace with

this.maxOrNull()

Since Kotlin

1.3