Specific Builder for Parameterized Type

◇◆丶佛笑我妖孽 提交于 2019-12-03 16:26:24

IterableLike (and the other XxxLike traits) abstract over the return type by delegating to a Builder that has to be specific for each collection type. Hence what you are trying cannot work.

You could create a generic wrapper MyWrapperLike[A, B] and a couple of specific wrappers MySeqWrapper[A] extends MyWrapperLike[A, Seq[A]] (same for Set, Map, List, etc.), i.e. mimic the design of the Scala collection library.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!