Scala for the Impatient 2nd Edition

Bug Report Page

.

How to Tell which Printing You Have

On the bottom of the copyright page (facing the first page of the table of contents), look for the very last line in the copyright page. It will look like 1 16, 2 17, and so on. The first number is the printing number.
In the errata below, we indicate the printing in which the error has been fixed inside square brackets such as [4].

For example, suppose you have the fourth printing. Then you can ignore all reports that are prefixed with [2], [3] or [4]. But you would want to pay attention to all reports that are prefixed with [5] or higher or that have no bracketed prefix at all.

Page 8
Change “If a package that starts with scala.” to “If a package starts with scala.
Page 9 [2]
Change def apply(n: Int): Char to def apply(i: Int): Char
Page 9 [2]
Change “You can use parentheses:” ("Bonjour".sorted)(3) to: “You can use another variable:”
val result = "Bonjour".sorted
result(3)
Page 22 [2]
Change import scala.io to import scala.io._
Page 35 [2]
Change JavaConversions to JavaConverters
Page 38 [2]
Change 0 until a.length by -1 to a.length -1 to 0 by -1, both above and in the tip.
Page 43 [2]
Change “Instead, import the implicit conversion methods in scala.collection.JavaConversions. Then you can use Scala buffers in your code, and they automatically get wrapped into Java lists when calling a Java method.” to “Instead, import the conversion methods in scala.collection.JavaConverters. Then you can call the asJava method to convert any sequence (such as a Scala buffer) into a Java list.”
Page 44 [2]
Change import scala.collection.JavaConversions.bufferAsJavaList to import scala.collection.JavaConverters._ and val pb = new ProcessBuilder(command) to val pb = new ProcessBuilder(command.asJava)
Page 44 [2]
Change “you can have it automatically converted into a Buffer” to “you can convert it into a Buffer
Page 44 [2]
Change import scala.collection.JavaConversions.asScalaBuffer to import scala.collection.JavaConverters._ and val cmd : Buffer[String] = pb.command() to val cmd : Buffer[String] = pb.command().asScala
Page 49 [2]
In the note, change scores1.get("Zelda") to scores1("Zelda") and scores2.get("Zelda") to scores2("Zelda")
Page 50 [2]
Remove “This is also useful if you want to work with a mutable tree map, which Scala doesn’t provide.”
Page 51 [2]
Change import scala.collection.JavaConversions.mapAsScalaMap to import scala.collection.JavaConverters._, change “Then trigger the conversion by specifying the Scala map type:” to “Then use the asScala method to turn the Java map into a Scala map:”, and change
val scores: scala.collection.mutable.Map[String, Int] =
  new java.util.TreeMap[String, Int]
to
val ids = java.time.ZoneId.SHORT_IDS.asScala
  // Yields a scala.collection.mutable.Map[String, String]
Page 51 [2]
Change
import scala.collection.JavaConversions.propertiesAsScalaMap
val props: scala.collection.Map[String, String] = System.getProperties()
to
val props = System.getProperties.asScala
  // Yields a Map[String, String], not a Map[Object, Object]
Page 51 [2]
Change “the opposite implicit conversion” to “the opposite conversion” and change
import scala.collection.JavaConversions.mapAsJavaMap
import java.awt.font.TextAttribute._ // Import keys for map below
val attrs = Map(FAMILY -> "Serif", SIZE -> 12) // A Scala map
val font = new java.awt.Font(attrs) // Expects a Java map
to
import java.awt.font.TextAttribute._ // Import keys for map below
val attrs = Map(FAMILY -> "Serif", SIZE -> 12) // A Scala map
val font = new java.awt.Font(attrs.asJava) // Expects a Java map
Page 69 Exercise 6 [2]
Change “Section 5.1, “Simple Classes and Parameterless Methods,” on page 55 to ”Section 5.2, “Properties with Getters and Setters” on page 56”
Page 104 [2]
Change f"$time04d" to f"$time%04d"
Page 104
Change MilTime lunch to val lunch
Page 148
Change val b = t1 to val b = t2
Page 111 [2]
Change Scala.io.readInt() to StdIn.readInt()
Page 112
Change String dirname to val dirname
Page 130
Change abstract override def log(msg: String) { ... } to abstract override def log(msg: String) {
Page 143
Change 1 .->(10) to 1.->(10)
Page 164
Change val listener = (event: ActionListener) => println(counter) to val listener = (event: ActionEvent) => println(counter)
Page 172 [2]
In the figure, change SortedSeq to SortedSet
Page 184
Change “The call c.reduceLeft(op)” to “The call coll.reduceLeft(op)
Page 190
Change words(5) // Aachen to words(4) // Aachen
Page 191 [2]
Change “The JavaConversions object” to “The JavaConverters object” and remove “Give the target value an explicit type to trigger the conversion.”
Page 191 [2]
Change
import scala.collection.JavaConversions._
val props: scala.collection.mutable.Map[String, String] = System.getProperties()
to
import scala.collection.JavaConverters._
val props = System.getProperties.asScala
Page 191 [2]
Change “If you are worried about unwanted implicit conversions, just import the ones you need, for example: import scala.collection.JavaConversions.propertiesAsScalaMap” to:
If you want to have complete control over the target type, use an explicit conversion function:
val propsMap = mapAsScalaMap(System.getProperties)
  // Yields a Map[Object, Object]
Page 191 [2]
Change val props: scala.collection.mutable.Map[String, String] = System.getProperties() to val props = System.getProperties.asScala
Page 192 [2]
In the tables, change “Implicit Function” to “Conversion Function”
Page 204 [2]
Change import scala.collection.JavaConversions.propertiesAsScalaMap to import scala.collection.JavaConverters._ and change System.getProperties() to System.getProperties.asScala (3x)
Page 218
Change “A type annotation must extend the TypeAnnotation trait” to “A type annotation must extend the TypeConstraint trait”
Page 223
In the note, change “This needs to be a parameterless function that also returns” to “This needs to be an expression that yields”
Page 231
In Figure 16-1, change Unparced to Unparsed
Page 257
Change Future[T] result = Future.firstCompletedOf(futures) to val result = Future.firstCompletedOf(futures)
Page 260 Exercise 1
Add a semicolon after for (n1 <- Future { Thread.sleep(1000) ; 2 }
Page 261 Exercise 2
Change “produces a function T => Future[U]” to “produces a function T => Future[V]
Page 283
Remove the / at the end of the second note
Page 309
Change “the value is now simply e” to “the value is now simply expr
Page 341 (3x), 342, 343, 344, 345, 348, 350, 351, 355 (2x) [2]
Change JavaConversions to JavaConverters

Thanks to Prashanth Babu, David Bendit, Nathan Brown, Michael Josephson, Mokhtar Khorshid, Artem Koval, Alex Levin, David Lott, M. Henry, Paul Nelson, Etienne Neveu, Maria Pacana, Etienne Richard, Juan Ignacio Santos Florido, Nico Serfontein, Bradley Smith, Marcel Stucki, Clark Verbrugg, Wei Zheng, and (your name might go here) for their bug reports and suggestions!

Bug Report Form

Please use this form to report any bugs that you find. Please check the list of known bugs first before you report a bug. Unfortunately, I do not have the time to respond personally to every report, but I do read them all and will post updates to this page. Thank you!

Your name:

Your email address:

Page number:

Problem description:

To protect against spam robots, please answer this simple math problem:
* =