This page lists errata for the book Programming in Scala.

Discussions also appear on the Programming in Scala forum on artima.com.

As you find errors, first check here and the Suggest link off your copy of scalabook.pdf to see if it has already been reported. If not, first report it to the authors via the Suggest link on your PDF. Only then should you add errata here, in page order using level 4 headings so that the table of contents links to individual pages.

p 49

If an anonymous function consists of one statement that takes a single argument, you need not explicitly name and specify the argument.

In addition, if you omit the argument, you also must omit the right arrow.

p 53

new String("Hello, world!")

is a horrible example, one which should be expunged from the Java programmer’s lexicon and which should not be introduced to Scala programmers. It might be better to show creating an instance of MyClass from p. 29, or

val l = new java.util.ArrayList(100)
l.add("Hello, World!")
println(l)

p 59

It is incorrect to sat that Nil Creates an empty List. Nil evaluates to an empty list; subsequent references to Nil return the same empty list.

Similarly, List() does not create a new list each time; it returns the same value as Nil

p 114

The result of 1/2 * 3/5 is 3/10 not 3/15

... rational numbers do not have state should be ... rational numbers do not have mutable state

It will augmented ... should be It will be augmented ....

The example is missing the closing right brace }

p 119

In class Rational, g should be initialized as

  private val g = gcd(n, d)

p 124

The four operators are not defined correctly: all incorrectly use this * new Rational(that), and each omitted the required return type.

The code should be

  def + (that: Int): Rational = this + new Rational(that)
  def - (that: Int): Rational = this - new Rational(that)
  def * (that: Int): Rational = this * new Rational(that)
  def / (that: Int): Rational = this / new Rational(that)

p 145

It creates a source file from the file name

should be It creates a Source object from the file name

p 152

Following

For instance, say you mistook the drop method of lists for tail, so you forgot that you need to pass a number to drop.

the example should show println(drop)

What would have happened is that the expression sqrt is treated as a function object

should be

What would have happened is that the expression drop is treated as a function object

p 161

 def withPrintWriter(file: File)(operation: PrintWriter => Unit) {

should be

 def withPrintWriter(f: File)(operation: PrintWriter => Unit) {

to match the use of f within this method, as well as the earlier example at the top of the page and on p 160.

p 169

lihe this should be like this

p 232

op ← opGroups(i).elements

should be

op ← opGroups(i)

 
language/programming-in-scala-errata.txt · Last modified: 2008/02/04 19:13 by djb
 
Recent changes RSS feed Valid XHTML 1.0 Driven by DokuWiki