Scala covariant type error

Viewed 362

I tried to define a class

abstract class Sequence[+A] {
    def append (x: Sequence[A]): Sequence[A]
}

and got in the terminal

<console>:8: error: covariant type A occurs in contravariant position in type Sequence[A] of value x
           def append (x: Sequence[A]): Sequence[A]

Why isn't this definition OK and what would be the best way to fix this? I checked this covariant type T occurs in contravariant position but nothing helpful for me there.

2 Answers
Related