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 a line such as
First printing, December 2016

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 35
Change JavaConversions to JavaConverters
Page 43
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
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
Change “you can have it automatically converted into a Buffer” to “you can convert it into a Buffer
Page 44
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 50
Remove “This is also useful if you want to work with a mutable tree map, which Scala doesn’t provide.”
Page 51
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
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
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 172
In the figure, change SortedSeq to SortedSet
Page 191
Change “The JavaConversions object” to “The JavaConverters object” and remove “Give the target value an explicit type to trigger the conversion.”
Page 191
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
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
Change val props: scala.collection.mutable.Map[String, String] = System.getProperties() to val props = System.getProperties.asScala
Page 192
In the tables, change “Implicit Function” to “Conversion Function”
Page 204
Change import scala.collection.JavaConversions.propertiesAsScalaMap to import scala.collection.JavaConverters._ and change System.getProperties() to System.getProperties.asScala (3x)
Page 341, 342, 343, 344, 345, 348, 350 (2x), 351, 354 (2x), 355 (2x)
Change JavaConversions to JavaConverters

Thanks to Mokhtar Khorshid 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:
* =