Relax upper bound of T for minBy and maxBy to be nullable.
Swap type parameters of minBy and maxBy. #KT-10099 Fixed
This commit is contained in:
@@ -1397,7 +1397,7 @@ public fun <T : Comparable<T>> Iterable<T>.max(): T? {
|
||||
/**
|
||||
* Returns the first element yielding the largest value of the given function or `null` if there are no elements.
|
||||
*/
|
||||
public inline fun <R : Comparable<R>, T : Any> Iterable<T>.maxBy(selector: (T) -> R): T? {
|
||||
public inline fun <T, R : Comparable<R>> Iterable<T>.maxBy(selector: (T) -> R): T? {
|
||||
val iterator = iterator()
|
||||
if (!iterator.hasNext()) return null
|
||||
var maxElem = iterator.next()
|
||||
@@ -1430,7 +1430,7 @@ public fun <T : Comparable<T>> Iterable<T>.min(): T? {
|
||||
/**
|
||||
* Returns the first element yielding the smallest value of the given function or `null` if there are no elements.
|
||||
*/
|
||||
public inline fun <R : Comparable<R>, T : Any> Iterable<T>.minBy(selector: (T) -> R): T? {
|
||||
public inline fun <T, R : Comparable<R>> Iterable<T>.minBy(selector: (T) -> R): T? {
|
||||
val iterator = iterator()
|
||||
if (!iterator.hasNext()) return null
|
||||
var minElem = iterator.next()
|
||||
|
||||
Reference in New Issue
Block a user