#scala #variances
The annotation +T
declares type T
to be used only in covariant positions.
If you want to change selection, open document below and click on "Move attachment"
Variances - Scala Documentation= sys.error("no element on stack")
override def toString() = ""
}
object VariancesTest extends App {
var s: Stack[Any] = new Stack().push("hello");
s = s.push(new Object())
s = s.push(7)
println(s)
}
<span>The annotation +T declares type T to be used only in covariant positions. Similarly, -T would declare T to be used only in contravariant positions. For covariant type parameters we get a covariant subtype relationship regarding this type parameter. For our exa Summary
status | not read | | reprioritisations | |
---|
last reprioritisation on | | | suggested re-reading day | |
---|
started reading on | | | finished reading on | |
---|
Details