By Developers, For Developers

Historical errata for Pragmatic Scala

PDF PgPaper PgTypeDescriptionFixed onComments
5ERROR

TopStock generates URLs of the form:

http: //ichart.finance.yahoo.com/table.csv?s=APPL&a=11&b=01&c=2014&d=11&e=31&f=2014&g=m

(extra space added after http because the errata submission form blocks links)

which for me at least are returning yahoo’s 404 page

2015-05-19Please replace APPL with AAPL (ticker symbol for Apple). Thanks.
52TYPO

The filename should be with a .scala extension, not with a .scalac one.

Extract: “To examine how the Scala compiler transformed the concise code into a full
blown class, compile the previous code using the command scalac CreditCard.scalac,
and run the command javap -private CreditCard to see what the compiler generated:”

2015-06-12
111TYPO

“If you want to convey the possible nonexistence of a value, use Optional, but to vary between possibly two different values, use Either.”

I believe you meant Option instead of Optional.

151ERROR

Dog.scala needs to override val name in initialize otherwise it won’t compile. Compilation error:

“Dog.scala:1: error: class Dog needs to be abstract, since value name in trait Friend of type String is not defined
class Dog(name: String) extends Animal with Friend {
^
one error found”

167ERROR

The example of filterNameStartWithDAndPragprogInFeed tries to filter urls with “pragprog” but the feeds Map only contains (“Dave Thomas” -> “pragdave.me”).

171ERROR

The output of “println(s​”All feeds have com: ${feeds.forall( _ contains “​com​” )}“​) is said to be ”All feeds have com: true" but the feeds List defined in page 170 contains “pragdave.me”.

172ERROR

The output of “println(s​”Feed url lengths: ${feeds.map( _.length ).mkString(“​, ​”)}“​)” is said to be “Feed url lengths: 17, 21, 23” but is “Feed url lengths: 17, 11, 23” given “pragdave.me” is the second string in the feeds List.

172ERROR

The output of:

val​ total = feeds.foldLeft(0) { (total, feed) => total + feed.length }​ \t
println(s​“Total length of feed urls: $total”​)”

Is said to be: “Total length of feed urls: 61” but is “Total Length of feed urls: 51”

19ERROR

The code example in chapter 1 uses the yahoo finance API (ichart.finance.yahoo.com), however, that API was discontinued in May of this year. Because of that the example no longer works, and running the example throws “java.net.UnknownHostException: ichart.finance.yahoo.com”.

I’d love to suggest an alternative, but google finance has also discontinued their API, and the other free alternatives require you to sign up first.

5ERROR

The website chart.finance.yahoo.com no longer exists, so it’s kinda hard to run the examples. The data is available elsewhere and can be massaged into file(s) to be read into a modified version of the program.

Categories: