332501 (2) [Avatar] Offline
#1
I've literally copied the code directly out of the book for Chapter 5 (early part of the chapter, where the Stream is being defined). When I try to add the headOption - exactly as it is in the book - the code won't compile. The code I entered (copied directly from the book) is here:

http://pastebin.com/rQQju4hS

and here are the errors:

http://pastebin.com/BhzCxGmn

I can figure out how to fix the first error, which is simply that we need to add the type parameter to the function definition (def headOption[A]: Option[A]). The first exercise (5.1) has the very same issue (def toList: List[A]). The other errors are harder to understand. Isn't Empty a type of Stream, from the "case object" declaration at the top of the code (and the same with Cons)?
332501 (2) [Avatar] Offline
#2
Ok, I think I have it. The headOption should be included as part of the trait, not the companion object. Is that correct?