Skip to content

Conversation

matetukacs
Copy link
Contributor

The last paragraph of the "types-variance" chapter explains how type variance applies to Scala functions.

In the last of the 3 examples that "illustrate the subtyping relationships induced by variance annotations on functions", there is a typo:
val h: Function[Book, Buyable] = g

g cannot be assigned to h, as B is not (and cannot) be contravariant.

I believe the intention was to assign g to f, to illustrate the contravariance of A.

Alternatively, the type of h can be modified to Function[Book, Item] to allow the assignment.

@julienrf julienrf merged commit 89bb804 into scala:main Oct 4, 2021
@julienrf
Copy link
Contributor

julienrf commented Oct 4, 2021

Good catch! 🤓

@matetukacs
Copy link
Contributor Author

Good catch! 🤓

thank you! 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants