Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Which is only because Java doesn't understand contravariance. In Scala, that problem no longer exists.


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...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: