From 2def921e6b9ec437ed3566556ac14be45ba7b9eb Mon Sep 17 00:00:00 2001 From: Justin Permar Date: Fri, 3 Nov 2017 14:44:05 -0400 Subject: [PATCH] add return type other than Unit onto the prepend() function in trait Bird I don't think this page intends to have a Unit return type for prepend. Without it, prepend() doesn't do anything useful: ```scala> birdList.prepend(new EuropeanSwallow)``` returns Unit. So add the return type so prepend() does what the reader expects it to. With the suggested change, I get ```scala> birdList.prepend(new EuropeanSwallow) res16: Node[Bird] = ListNode(EuropeanSwallow(),ListNode(AfricanSwallow(),Nil()))``` --- _tour/lower-type-bounds.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_tour/lower-type-bounds.md b/_tour/lower-type-bounds.md index b81c0829ba..16f160c465 100644 --- a/_tour/lower-type-bounds.md +++ b/_tour/lower-type-bounds.md @@ -42,7 +42,7 @@ To fix this, we need to flip the variance of the type of the parameter `elem` in ```tut trait Node[+B] { - def prepend[U >: B](elem: U) + def prepend[U >: B](elem: U): Node[U] } case class ListNode[+B](h: B, t: Node[B]) extends Node[B] {