I was trying to write some simple method toList
...
trait Stream[+A] {
def uncons: Option[(A, Stream[A])]
def isEmpty: Boolean = uncons.isEmpty
def toList[A]: List[A] = this.uncons match {
case Some((h,t)) => h::t.toList
case None => List()
}
}
however, this results in the following error:
type mismatch; found : x$1.type (with underlying type A) required: A
I don't understand why this code doesn't work. Probably I am missing something very obvious :(