Tag: 最大

标准的二进制maxBy函数

我概括了下面的代码: fun max(that: Type): Type = if (this.rank() < that.rank()) that else this 对此: fun max(that: Type): Type = maxBy(this, that) { it.rank() } fun maxBy<T, U : Comparable<U>>(a: T, b: T, f: (T) -> U): T = if (f(a) < f(b)) b else a 在Kotlin的标准库中是否有像maxBy这样的函数? 我只能找到一个数组。