3 ms·
Covariance can be thought of as a mechanism for overriding functions. Assume there is a (base) function f: X -> Y We want to override it by providing a ne
by asavinov 9y ago
Covariance can be thought of as a mechanism for overriding functions. Assume there is a (base) function
f: X -> Y
We want to override it by providing a new mapping from U to V:
f: U -> V
This mechanism is said to be covariant if the new function guarantees that
If u <: x then v=f(u) <: y=f(x)
This means that for each more specific input u in U the function returns more specific (not more general) output v in V.