The signature of reduceLeft
on some Seq[A]
is
def reduceLeft [B >: A] (f: (B, A) => B): B
The type of A
is known, but the lower bound >:
tells us that B
can be any supertype of A
.
Why is it like this? Why not
def reduceLeft (f: (A, A) => A): A
We already know that the head of the sequence is type A
and so I can't think of how B
could be anything other than equal to A
. Can you provide an example where B
is some super-type?