I want to just reverse the items in this collection, so I decided to require that it be part of Traversable
, and any of the subtypes for it, and have it return a Traversable, but I think I may need to use a variance on that also, but, at the moment I get a compiler error, using Scala 2.10.0-M5.
trait Polynomials {
def coefficients[+A <: Traversable[T]](x:A):Traversable[A] = x.foldLeft(Traversable[A]())((b,a) => a :: b)
}
These are the errors I am getting, and I am not certain what I did wrong.
Description Resource Path Location Type
']' expected but identifier found. Polynomials.scala line 4 Scala Problem
'=' expected but ']' found. Polynomials.scala line 4 Scala Problem
illegal start of simple expression Polynomials.scala line 5 Scala Problem