I’m trying to work out how all the traits like Seq, Iterable, Traverable, TraversableLike all work together.
I’m slowly getting a bit of a spider web diagram, as I try and draw the relationships in a UML class diagram.
Is there a reason that for example scala.collection.immutable.Seq inherits from scala.collection.generic.GenericTraversableTemplate, even though it inherits that trait from its parent scala.collection.immutable.Iterable?
The collections API seems to be full of duplicated inheritances, which is leading me to think I haven’t understood something…
Cheers,
Ant
trait Seq [+A] extends Iterable[A] with Seq[A] with GenericTraversableTemplate[A,Seq] with SeqLike[A, Seq[A]] with Parallelizable[A, ParSeq[A]]trait Iterable [+A] extends Traversable[A] with Iterable[A] with GenericTraversableTemplate[A,Iterable] with IterableLike[A, Iterable[A]] with Parallelizable[A, ParIterable[A]]As you can see,
SeqandTraversableactually extendGenericTraversableTemplatewith different type parameters, so that, for example, methodflattenhas appropriate return type in each case.