inline fun <T, K, R> Grouping<T, K>.fold(
initialValueSelector: (key: K, element: T) -> R,
operation: (key: K, accumulator: R, element: T) -> R
): Map<K, R>
Semi related but the relationship between
aggregate
and
fold
for
Grouping
seems kind of fuzzy to me. It seems like this version of
fold
is just an awkward, two lambda version of aggregate. But then, the simplest case is handled most nicely by the
fold
overload taking a simple initial value. So the useful functionality is kind of spread between them, and yet aggregate is missing the most useful overload (IMHO).
Just curious if there are reasons I'm missing why the API is this way. The first time I went to use
Grouping
it felt a bit clunkier than I'm used to in Kotlin.