#scala #variances
the type defined by the class Stack[T]
is subject to invariant subtyping regarding the type parameter.
If you want to change selection, open document below and click on "Move attachment"
Variances - Scala Documentationns may be added when a class abstraction is defined, whereas in Java 5, variance annotations are given by clients when a class abstraction is used.
In the page about generic classes an example for a mutable stack was given. We explained that <span>the type defined by the class Stack[T] is subject to invariant subtyping regarding the type parameter. This can restrict the reuse of the class abstraction. We now derive a functional (i.e. immutable) implementation for stacks which does not have this restriction. Please note that this is Summary
status | not read | | reprioritisations | |
---|
last reprioritisation on | | | suggested re-reading day | |
---|
started reading on | | | finished reading on | |
---|
Details