Problematic combination of variance in Scala -
here example scala course on coursera:, lecture 4.4
class array[+t] { def update(x: t) = ??? }
this causes error in repl:
error: covariant type t occurs in contravariant position in type t of value x
and on slides, martin says "problematic combination". why so?
this explained in "variance , arrays" section of http://www.artima.com/pins1ed/type-parameterization.html (from programming in scala odersky, venners, , spoon).
Comments
Post a Comment