The Artima Developer Community


Errata for Programming in Scala, 2nd Edition
Chapter 19: Type Parameterization
Return to errata index.

Page 393 (PDF page 430):
In the second paragraph, right after the code example, it says "then if T
is a subtype of type S, this would imply that Queue[S] is a subtype of
Queue[T]" I guess it should be "then if S is a subtype of type T..."
Page 393 (PDF page 430):
I read the errate corrige relate this Page :
"
  Page 393 (PDF page 430):
  In the second paragraph, right after the code example, it says
  "then if T is a subtype of type S, this would imply that Queue[S] 
  is a subtype of Queue[T]" I guess it should be "then if S is a 
  subtype of type T..."
"

This correction is WRONG :
the text in book is correct because with controvariance 
   is T is a subtype of S thus ==> Queue(S) is subtype Queue(T)
Page 399 (PDF page 430):
chapter 19 appears to either have an error or I am compiling the code
incorrectly:
The following will not compile in Eclipse:
/** specialization of the Queue[T] trait to Int **/
class StrangeIntQueue extends Queue[Int] {
  override def enqueue(x: Int) = {
    println(math.sqrt(x))
    super.enqueue(x)      // THIS DOES NOT COMPILE
  }
}

The compiler error:
method enqueue in trait Queue is accessed from super. It may not be
abstract unless it is overridden by a member declared abstract' and
override'
Page 399 (PDF page 436):
I'm not sure but this page does not seem correct:
this is text of book: (the sign after T,W,U are intended as superscript)

abstract class Cat[-T,+U] {
   def meow[W-]( volume: T-,listener: Cat[U+, T-]-)
      :   Cat[Cat[U+, T-]- , U+]+
}   
This definition seems to contradict what is said later:
" .... In this case T is only used in negative positions and U is only
used in positive positions... "


the correct form should be:

abstract class Cat[-T,+U] {
   def meow[W-]( volume: T- ,listener: Cat[T-,U+]-)
      :   Cat[Cat[T-, U+]- , U+]+
}   

it would not hurt if the example was explained in a little more detail

Page number: Book type: Paperback book PDF eBook
Book version: (Or build date. Found on back of title page.)
Your feedback:
Your name: (optional)
Your email address: (optional) (will not be published)

Copyright © 2021 Artima, Inc. All rights reserved.