Programming Scala

Errata for Programming Scala

Submit your own errata for this product.


The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

Color Key: Serious Technical Mistake Minor Technical Mistake Language or formatting error Typo Question Note Update



Version Location Description Submitted By Date Submitted Date Corrected
Printed
Page Back cover of print edition
last paragraph on the left-hand side

A reader pointed this out to me. It looks like the paragraph might be from "Mining the Social Web", which uses iPython notebooks. How about this rewrite: The example source code for this book is maintained in a public github repository. Add the URL? (There isn't one in the current paragraph.) Should there be more in this paragraph?

Dean Wampler
Dean Wampler
O'Reilly Author 
Dec 17, 2014 
Safari Books Online
Chapter 1, Zero to Sixty: Introducing Scala, A Taste of Scala

Immediately following the last "NOTE" box in this section, the text reads: "The first code line in the file defines the package for the type, named intro." This refers to the listing for upper1.scala. In the listing shown, however, the package is named introscala.

Note from the Author or Editor:
Correct. Should be "... named introscala."

James Kubecki  Feb 22, 2015 
Safari Books Online
Chapter 4, Matching on Case Classes

In code: // src/main/scala/progscala2/patternmatching/match-deep.sc There is a missing right parenthesis at the line: case Person("Alice", 25, Address(_, "Chicago", _) => println("Hi Alice!")

Note from the Author or Editor:
Good catch. Should be: case Person("Alice", 25, Address(_, "Chicago", _)) => println("Hi Alice!")

Eric B  Feb 21, 2015 
Printed
Page 6
3rd paragraph

No mistake in the book but in the projectcode from github. After running the help and eclipse tasks, importing of the code examples in Eclipse didn't succeed because the colon in the projectname (after "Second Edition") was not accepted. I had to remove it first in the xml.

Note from the Author or Editor:
I changed the project name in the github repo's "build.sbt". It should now work.

Hans de Jong  Feb 08, 2015 
PDF
Page 16
6th (second to last)

"Because map takes a single function argument, where the function itself takes a single argument." is a clause. I think removing the leading "Because" will fix it.

Note from the Author or Editor:
Yes, change "Because" to "The".

Chris Simpkins  Aug 23, 2014  Nov 25, 2014
PDF
Page 18
1st paragraph, 4th line

s/imaging/imagine/

Note from the Author or Editor:
correct

Chris Simpkins  Aug 23, 2014  Nov 25, 2014
PDF
Page 21
code section 3rd paragraph

scala> import progscala2.introscala.shapes._ import progscala2.introscala.shapes._ scala> val p00 = new Point p00: progscala2.introscala.shapes.Point = Point(0.0,0.0) scala> val p20 = new Point(2.0) p20: progscala2.introscala.shapes.Point = Point(2.0,0.0) scala> val p20b = new Point(2.0) p20b: progscala2.introscala.shapes.Point = Point(2.0,0.0) scala> val p02 = new Point(y = 2.0) p02: progscala2.introscala.shapes.Point = Point(0.0,2.0) scala> p00 == p20 res0: Boolean = false scala> p20 == p20b res1: Boolean = true

Note from the Author or Editor:
Correct. The initial import statement and the "echo" on the next line should have "progscala2." prefixes. I found some other mistakes like this that I'll email to the production team, as well.

Vincent Ohprecio  Aug 31, 2014  Nov 25, 2014
PDF
Page 22
2nd paragraph, last sentence

s/to to/to do/

Note from the Author or Editor:
correct.

Chris Simpkins  Aug 23, 2014  Nov 25, 2014
PDF
Page 34
First line

s/can want to/can/

Note from the Author or Editor:
Doh! correct

Chris Simpkins  Aug 24, 2014  Nov 25, 2014
PDF
Page 35
4th and 5th paragraphs in the Partial Functions section

"This function avoids the risk of throwing a MathError exception..." 'MathError' should probably be MatchError "A MathError is only thrown..." Same here

Note from the Author or Editor:
Damn. It should be MatchError.

Anonymous  Dec 07, 2014 
PDF
Page 46
Code Example

On page 46, line 5 (excluding white spaces) of the formatted code example should be p.age and not p.lastName

Note from the Author or Editor:
Correct. It should be "p.age". Copy, paste error...

Ajeya Vempati  Jun 01, 2014  Nov 25, 2014
PDF
Page 50
5th Paragraph

In the section, "Methods with Multiple Argument Lists", in page 51, the author starts the last paragraph with "The third advantage ...". Am I missing another advantage #2? I am assuming advantage #1 is being able to use the 'syntactic sugar' advantage of being able to use '{}' vs '()'.

Note from the Author or Editor:
Yes, no explicit "second" advantage is mentioned. I've "renumbered" them to have a total of 3, not 4.

Anonymous  Jun 01, 2014  Nov 25, 2014
PDF
Page 55
3rd Paragraph

The last sentence in paragraph 3 reads as "Fortunately, Java 8 finally adds clojures to Java.". I think, this is what the author meant "Fortunately, Java 8 finally adds closures to Java."

Note from the Author or Editor:
Doh! Yes, "closures" is the correct work.

Anonymous  Jun 01, 2014  Nov 25, 2014
PDF
Page 60
First line under heading Option, Some, and None: Avoiding nulls

s/three useful type/three useful types/ (add an 's' to "type").

Note from the Author or Editor:
Correct.

Chris Simpkins  Aug 24, 2014  Nov 25, 2014
PDF
Page 98
source code - object manage

In code snippet of apply manage val/val error. Resource close never because symbol 'res' define two time in different scope: var res: Option[R] = None // first time as mutable val res = Some(resource) // second time as immutable in try scope... In 'finally' scope using 'var res' which is never 'None'.

Note from the Author or Editor:
Correct. The "val res = Some... should not have the "val". Fixed in the next early-access release.

Andrew Rochev  Aug 12, 2014  Nov 25, 2014
PDF
Page 132
Result of code snippet

This string "list double" is in result of code snippet page 132. But this string in not in code. It is copy past error.

Note from the Author or Editor:
Correct. Will fix in final version.

Andrew Rochev  Jul 23, 2014  Nov 25, 2014
PDF
Page 150
1st paragraph

The overridingConversion code could not be found

Note from the Author or Editor:
The wrong source file was included here (i.e., the previous file was included in the text twice). There are only two changes, however: 1. The comment with the file name should end with .../implicit-conversions-resolution2.sc 2. There is a new line of text before the definition of "class O": implicit def overridingConversion(s: String): Foo = Foo("Boo: "+s)

Winson Kwok  Jan 07, 2015 
PDF
Page 152
end of page and beginning of page 153

Just a suggestion: instead of using Int and String as the markers for your examples, consider using marker classes, like so, and also mentioning why using common classes like Int and String is not a good idea: class IntMarker class StringMarker object M { def m(seq: Seq[Int])(implicit i: IntMarker): Unit = println(s"Seq[Int]: $seq") def m(seq: Seq[String])(implicit i: StringMarker): Unit = println(s"Seq[String]: $seq") } implicit val anIntMarker = new IntMarker implicit val aStringMarker = new StringMarker M.m(List(1,2,3)) M.m(List("one", "two", "three"))

Note from the Author or Editor:
Good idea. I changed the example accordingly.

Robert Yacobellis  Aug 17, 2014  Nov 25, 2014
PDF
Page 153
Last paragraph

First, we won�t hande arrays or nested objects, just �flat� JSON expressions like {"a": "A", "b": 123, "c": 3.14159} May be - First, we won�t HANDLE arrays or nested objects, .....

Note from the Author or Editor:
Fixed.

alex.menshov.1@facebook.com  Aug 20, 2014  Nov 25, 2014
PDF
Page 322
2nd paragraph

The fourth line of second paragraph: attempts to use override val name = "foo" I think it should be override var name = "foo" i.e. an attempt to use var to override a parameterless method will get an error

Note from the Author or Editor:
Correct, it should be "var" not "val". There is also another typo in the first sentence of the same paragraph, "... writer method, override name_=, ..." There should be a "def" between "override" and "name".

Winson Kwok  Jan 08, 2015 
PDF
Page 354
Code example, first method (equalsFields)

def equalFields(other: ProtectedClass1) = (protectedField1 == other.protectedField1) && (protectedField1 == other.protectedField1) && (nested == other.nested) should be def equalFields(other: ProtectedClass1) = (protectedField1 == other.protectedField1) && (protectedField2 == other.protectedField2) && (nested == other.nested)

Dean Wampler
Dean Wampler
O'Reilly Author 
Aug 28, 2014  Nov 25, 2014
PDF
Page 427
last line

The regular expression: val blankRE = """^\s*#?\s*$""".r is claimed to be: "a matcher for blank lines (or “comments,” lines where the first non- whitespace character is a #), which are ignored." However any non-whitespace after a # will cause the match to fail. I believe you intended something more like: val blankRE = """^\s*(?:#.*)?\s*$""".r

Note from the Author or Editor:
The proposed change to blankRE is what it should be.

Eric Wasserman  Feb 05, 2015 
PDF
Page 482
4th paragraph

Broken link to sbt-web in 'By now you’ve installed SBT. If you do JVM-based web development, see also the new sbt-web project" ->https://github.com/sbt/sbt-web$$

Note from the Author or Editor:
The dollar signs "$$" shouldn't be at the end of the URL. I don't know how they got there.

Anonymous  Jan 31, 2015 
Printed, PDF
Page 517
1st paragraph

First sentence: "... that manipulates programs, rather than data", should really read "that manipulates programs as data".

Dean Wampler
Dean Wampler
O'Reilly Author 
Jan 05, 2015 
Printed, PDF, ePub
Page 517
2nd to last sentence of last paragraph

"... we'll focus on the most stable parts: runtime reflection..." Change "runtime" to "runtime and compile-time" (drop the hyphen if you prefer...)

Dean Wampler
Dean Wampler
O'Reilly Author 
Jan 05, 2015 
Printed, PDF, ePub
Page 518
last paragraph in the "Tools for ..." section

" scala.reflect.api.Types.TypeRef and scala.reflect.api.Symbols.TypeSymbol" should be " scala.reflect.api.Types#TypeRef and scala.reflect.api.Symbols#TypeSymbol". That is, the last period in each name should be a # instead. The links work correctly, fortunately.

Dean Wampler
Dean Wampler
O'Reilly Author 
Jan 05, 2015 
Printed, PDF, ePub
Page 520-522
"match-types.sc" example

This example is actually nonsense for reasons I won't elaborate here. It would be best to remove it completely. I recommend the following changes. 1. Delete the paragraphs starting at "We saw in "More on Type Matching"..." through to the single-sentence paragraph "However, as mentioned, it's not accurate for Seq[Any] with mixed elements, the second to last example". on pages 520-521. 2. Move the example at the end of this section, mkArray.sc, in its place. Starting at the paragraph on pg. 522: "Another important usage or ClassTag ...", plus the mkArray.sc example, and finally the paragraph "It uses the Array.apply method for AnyRefs, which has a second argument list with a single implicit ClassTag argument". However, change the leading words, "Another important ..." to "An important usage..." 3. With this example moved, the last paragraphs will now be the ones I didn't mention that are unchanged: "The compiler exploits the type information... "Hence, ClassTags can't "resurrect" type information... "ClassTag is actually a weaker version of ... "Note that there are older types in the ... <end of section> (Actually, there is a correction for the last paragraph that I suggested in another bug report.)

Dean Wampler
Dean Wampler
O'Reilly Author 
Jan 05, 2015 
Printed, PDF, ePub
Page 522
2nd sentence in the 1st full paragraph

"These types are being deprecated." Change to "These types will be deprecated eventually."

Dean Wampler
Dean Wampler
O'Reilly Author 
Jan 05, 2015 
Printed, PDF, ePub
Page 527
First sentence in the last paragraph

"... syntax expands the list into comma-separated values" should be "... syntax expands the list into a list of trees"

Dean Wampler
Dean Wampler
O'Reilly Author 
Jan 05, 2015 
Printed, PDF, ePub
Page 528
First sentence in the second paragraph

"Recall that we said that macros are a limited form of compiler plug-in" would be more accurately put, "Recall that we said that macros work like a limited form of compiler plug-in"

Dean Wampler
Dean Wampler
O'Reilly Author 
Jan 05, 2015 
Printed, PDF, ePub
Page 528
Code example under "A Macro Example..."

The line "import reflect.runtime.universe._" should be there. (It can cause problems in some cases). So, it should be removed, but the "1" bullet should be moved to the next line, "import scala.language.experimental.macros".

Dean Wampler
Dean Wampler
O'Reilly Author 
Jan 05, 2015 
ePub
Page 553
Table 10-1

In the table 10-1 "Type variance annotations and their meanings" the entry for contravariance contradicts the definition I have seen elsewhere. The book shows: -T means Contravariant. E.g., X[Tsup] is a supertype of X[T]. I have read in other sources: -T means Contravariant. E.g., X[Tsup] is a subtype of X[T] Which one is right?

Note from the Author or Editor:
Yikes. It should say "X[Tsup] is a subtype of X[T]"

John Ferguson  Nov 19, 2014  Nov 25, 2014