Hi everyone, first time here.
I have a question about API design of IterableOnceOps , IterableOps and Iterator. The same question was posted on scala gitter, not didn’t got any response. So I thought repost here.
Looking at various methods declared/defined in IterableOnceOps , IterableOps and Iterator , it comes to me the following question:
Why are some operation methods declared/defined in IterbleOnceOps , then get implemented/overriddn in IterableOps and Iterator , while some others are declared/defined separately both in IterableOps and Iterator without a general declaration/definition in IterableOnceOps ?
I know some methods don’t make sense for one trait or another, therefore not suitable to be placed in IterableOnceOps .
But as I checked, zip , zipWithIndex , zipAll , scanLeft , partition , concat are all implemented for IterableOps and Iterator , and all these methods can be genericly declared in IterableOnceOps . But only zipWithIndex is actually declared in IterableOnceOps .
Taking zip as an examle.
IterableOps.zip has the following signature:
def zip[B](that: IterableOnce[B]): CC[(A @uncheckedVariance, B)]
Iterator.zip has the following definition snippet:
def zip[B](that: IterableOnce[B]): Iterator[(A, B)]
They could be genericly declared as IterableOnceOps.zip :
def zip[B](that: IterableOnce[B]): CC[(A @uncheckedVariance, B)]
This is exactly the case done for zipWithIndex .
So, why is only zipWithIndex declared in IterableOnceOps , but for zip , zipAll , scanLeft , partition , concat , they are not declared in IterableOnceOps ?