|
|
|
|
|
by saghm
2089 days ago
|
|
> If you can upcast Cat to Animal, why can Cat[] not be converted to Animal[] in the same way? Basically, because it's not type safe (for the reason I gave above). It doesn't really help expressivity to be able to assign a Cat[] to an Animal[], but as you can only use it safely if you only put cats in it, so you might as well just make the variable Cat[] instead of Animal[]. See the section on arrays in this wikipedia article: https://en.wikipedia.org/wiki/Covariance_and_contravariance_... |
|