minOf
minOf is a function in Kotlin's standard library that returns the smallest element among given values or among the elements of a collection, according to a defined ordering. It is the counterpart to maxOf and is used to simplify comparisons without writing explicit if statements. The function provides several overloads: a two-value variant for comparable types, an overload that accepts a comparator, and versions that operate on iterables or arrays of values.
When called with two values that are comparable, minOf(a, b) returns the value with the smaller natural
Examples: minOf(3, 7) returns 3. minOf("kotlin", "java") returns "java" since it is lexicographically smaller. minOf(listOf(5, 1,
See also: maxOf, min, and the related minOrNull for safely handling empty inputs.