Re:Inheritance Often Doesn't Make Sense
by fnl on Saturday March 17, 2018 @07:14AM
(#16606455)
Which is only because Java doesn't understand contravariance. In Scala, that problem no longer exists.
[ Parent
| on HN ]
No. When references or arrays of references are treated as contravariant, you would have the opposite problem of ArrayReadException. You can now store things into arrays safely but you can no longer extract things from arrays safely.
Consumers are contravariant in Scala, but producers are covariant.
EDIT: Good reference: https://www.atlassian.com/blog/software-teams/covariance-and...