Errata (1st Edition)

Last updated: 10/22/2018

  • On page 74, an invocation of runSimulation(String, (String, Int) -> String) in Listing 5.8 is changed from Listing 5.7. It should be struckthrough.
  • On page 131, the following sentence is duplicated: “The read-only nature of the list has nothing to do with the val or var keyword you used to define the list variable. Changing the variable declaration for patronList from val (as it is defined now) to var would not change the list from read-only to writable. Instead, you would be able to reassign the patronList variable to hold a new, different list.”
  • In Chapter 13, a series of code listings shows a multi-line primary constructor without commas to delimit parameters.
  • On page 193, the castFireball output begins referring to the glass of fireball as “delicious”, which does not appear in the function output previously.
  • On page 238, the argument to the when expression in the informal example below Figure 15.4 should be named status, not studentStatus.
  • On page 248, Listing 16.4 implements a random dice roll that suggests the idea of a zero-sided die. A more appropriate algorithm should include Random().nextInt(diceSides) + 1 instead of Random().nextInt(diceSides + 1).
  • On page 279, Listing 18.16 should be labelled as contents of Player.kt, not Tavern.kt.