Skip to content

Commit 0063e21

Browse files
Merge pull request #865 from lierdakil/lower-type-bounds
fixes for tour/Lower type bounds
2 parents ea93b69 + c48688c commit 0063e21

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

_tour/lower-type-bounds.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ To fix this, we need to flip the variance of the type of the parameter `elem` in
4242

4343
```tut
4444
trait Node[+B] {
45-
def prepend[U >: B](elem: U)
45+
def prepend[U >: B](elem: U): Node[B]
4646
}
4747
4848
case class ListNode[+B](h: B, t: Node[B]) extends Node[B] {
@@ -58,13 +58,13 @@ case class Nil[+B]() extends Node[B] {
5858

5959
Now we can do the following:
6060
```tut
61-
trait Mammal
62-
case class AfricanSwallow() extends Mammal
63-
case class EuropeanSwallow() extends Mammal
61+
trait Bird
62+
case class AfricanSwallow() extends Bird
63+
case class EuropeanSwallow() extends Bird
6464
6565
6666
val africanSwallowList= ListNode[AfricanSwallow](AfricanSwallow(), Nil())
67-
val mammalList: Node[Mammal] = africanSwallowList
68-
mammalList.prepend(new EuropeanSwallow)
67+
val birdList: Node[Bird] = africanSwallowList
68+
birdList.prepend(new EuropeanSwallow)
6969
```
70-
The `Node[Mammal]` can be assigned the `africanSwallowList` but then accept `EuropeanSwallow`s.
70+
The `Node[Bird]` can be assigned the `africanSwallowList` but then accept `EuropeanSwallow`s.

0 commit comments

Comments
 (0)