Why does `fun <S, T : S> Iterable<T>.r...
# getting-started
l
Why does
fun <S, T : S> Iterable<T>.reduce(operation: (acc: S, T) -> S): S
have two generic type parameters (
S
and
T
) when it operates on the same collection? In its source code
acc
is taken from the
Iterable<T>
so
S
is always the same type as
T
anyway.
Ok, I see,
T : S
, so
S
can be a supertype of
T
.
nod 2