Skip to content

Commit

Permalink
fixed maxBy compare param signature (#224)
Browse files Browse the repository at this point in the history
  • Loading branch information
ezamagni committed Apr 8, 2022
1 parent c1a07e4 commit e83c373
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/src/functions.dart
Expand Up @@ -87,14 +87,14 @@ S? minBy<S, T>(Iterable<S> values, T Function(S) orderBy,
///
/// Returns `null` if [values] is empty.
S? maxBy<S, T>(Iterable<S> values, T Function(S) orderBy,
{int? Function(T, T)? compare}) {
{int Function(T, T)? compare}) {
compare ??= defaultCompare;

S? maxValue;
T? maxOrderBy;
for (var element in values) {
var elementOrderBy = orderBy(element);
if (maxOrderBy == null || compare(elementOrderBy, maxOrderBy)! > 0) {
if (maxOrderBy == null || compare(elementOrderBy, maxOrderBy) > 0) {
maxValue = element;
maxOrderBy = elementOrderBy;
}
Expand Down

0 comments on commit e83c373

Please sign in to comment.