How can Seq[+A] be covariant in A if A occurs in contravariant position:
def :+ (elem: A) : Seq[A] ?
As I understand, a method argument type is a contravariant position. What am I missing ?
That's the use case signature. It is not a real signature, just what you'll usually see in the common use case.
The real signature is:
def :+ [B >: A, That] ( elem : B )(implicit bf : CanBuildFrom[Seq[A], B, That] ) : That
Which, as you see, doesn't even guarantee a Seq
return, much less A
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With