Skip to content

Commit 02376d1

Browse files
authored
Merge pull request #2145 from mikkelmilo/patch-1
Nit: Change "Writer" to "Printer" in contravariance example
2 parents 70434b6 + 3f4a537 commit 02376d1

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)