Skip to content

Commit 3f4a537

Browse files
authoredJul 29, 2021
Change "Writer" to "Printer"
The contravariance example uses the `Printer` class, so the text should use this name instead of `Writer` to avoid confusion. Unless I am missing something?
1 parent 86172db commit 3f4a537

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed
 

‎_tour/variances.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ printAnimalNames(dogs)
5454

5555
### Contravariance
5656

57-
A type parameter `A` of a generic class can be made contravariant by using the annotation `-A`. This creates a subtyping relationship between the class and its type parameter that is similar, but opposite to what we get with covariance. That is, for some `class Writer[-A]`, making `A` contravariant implies that for two types `A` and `B` where `A` is a subtype of `B`, `Writer[B]` is a subtype of `Writer[A]`.
57+
A type parameter `A` of a generic class can be made contravariant by using the annotation `-A`. This creates a subtyping relationship between the class and its type parameter that is similar, but opposite to what we get with covariance. That is, for some `class Printer[-A]`, making `A` contravariant implies that for two types `A` and `B` where `A` is a subtype of `B`, `Printer[B]` is a subtype of `Printer[A]`.
5858

5959
Consider the `Cat`, `Dog`, and `Animal` classes defined above for the following example:
6060

0 commit comments

Comments
 (0)
Please sign in to comment.