Open SethTisue opened 6 years ago
Option.fold
was added by @paulp in 2012. it's unclear to me if the question of 1-or-2-parameter-lists was considered at the time or not
there is also the question of consistency with the signature of Iterable.fold
and friends, of course; that might have been the motivation for going with two parameter lists
Either#fold
has one parameter list,def fold[C](fa: A => C, fb: B => C): C
but
Option#fold
has two,def fold[B](ifEmpty: => B)(f: A => B): B
as shown in #9262, the single-parameter-list version offers better type inference
it's also simply confusing that the two are different
fwiw, the difference goes away in Dotty, which can infer the right type either way:
given that the improvement in type inference is coming in Dotty, it might still be worth bringing the two in line for consistency's sake? I fear it's not worth breaking existing code
reported by @Jacoby6000 on #scala IRC