docs.scala-lang
docs.scala-lang copied to clipboard
Adding custom collection operation which restricts element type of the input collection (documentation needs improving)
The documentation on adding custom operations to collections does not go into any detail about how to add operations to collections of particular element types. As per my stackoverflow question, I don't know how to translate the 2.12 method signature:
def split[X, CC[X] <: Traversable[X], A, B](l : CC[Either[A, B]])(implicit bfa : CanBuildFrom[Nothing, A, CC[A]], bfb : CanBuildFrom[Nothing, B, CC[B]]) : (CC[A], CC[B])
Into 2.13 idiomatic style and implement it. The SO question demonstrates one way I solved the problem using the documentation but it requires type parameters to be supplied at the use-site.
It would be good if the documentation could expressly demonstrate how to solve this sort of thing