I want to define a transformation of a generic collection.
def transform[S<:GenIterable[T],T](s:S):S = s.zipWithIndex
This throws:
type mismatch; found : scala.collection.GenIterable[(T, Int)] required: S
I have to declare S
as a parameterized GenIterable
in the function definition. I'd like to specify an output type of "whatever the collection type was that created S
, except parameterized with [(T,Int)]
", so that I'm guaranteed to get the same collection type back, and not just GenIterable
.
How can I make that happen?