We try to keep our books accurate, but sometimes mistakes creep
in. This page lists the errors submitted by our astute readers.
If you've found a new error, please
submit it.
The latest version of the book is P1.0,
released over 2 years ago.
If you've bought a PDF of the book and would like to upgrade
it to this version (for free), visit your
home page.
| PDF |
Paper |
Description |
Found in |
Fixed in |
| 38 |
|
#40517: The text in chapter: Getting up to speed in Scala (excerpt), page #38, specifies, "So, calling 1 to 3 is equivalent to 1.to(3), but the former is more elegant". Expression 1.to(3) should be expressed as (1).to(3), as Scala's lexer uses longest match rule for tokens and in expression 1.to(3), 1. will be considered as 1.0, a Double rather than an Int.--Sankar Ammaiyappan #40517: The text in chapter: Getting up to speed in Scala (excerpt), page #38, specifies, "So, calling 1 to 3 is equivalent to 1.to(3), but the former ...more...
|
P1.0
20-Aug-09
|
|
| 40 |
|
#47936: The words "do for" in the code snippet is overstriked. Is that a typo?--Kirin
|
P1.0
11-Nov-11
|
|
| 49 |
|
#41155: It is not evident (at least not to me) that the Protected.scala examples cannot be run from the interpreter. Since this is the first time in the book this appears, it might get exaplined later, but at this page you have no idea why running with scala fails and only scalac shows the error you mention.--Erik Dyrelius #41155: It is not evident (at least not to me) that the Protected.scala examples cannot be run from the interpreter. Since this is the first time in t ...more...
|
P1.0
01-Nov-09
|
|
|
52 |
#47538: Marker.scala does not compile on Scala 2.9.
<console>:10: error: constructor Marker in class Marker cannot be accessed in object Marker
"red" -> new Marker("red"),
^
<console>:11: error: constructor Marker in class Marker cannot be accessed in object Marker
"blue" -> new Marker("blue"),
^
<console>:12: error: constructor Marker in class Marker cannot be accessed in object Marker
"green" -> new Marker("green")--Ian Eure #47538: Marker.scala does not compile on Scala 2.9.
<console>:10: error: constructor Marker in class Marker cannot be accessed in object Marker
...more...
|
P1.0
10-Sep-11
|
|
|
61 |
#47256: The code sample (SensibleTyping/Methods.scala) does not work as either a stand-alone script or when the code is transplanted to a class. In either scenario it throws a NoSuchMethodException. #47256: The code sample (SensibleTyping/Methods.scala) does not work as either a stand-alone script or when the code is transplanted to a class. In ei ...more...
|
P1.0
08-Jul-11
|
|
| 64 |
|
#48066: It seems that in Generics.scala more is shown than is intended. I suspect that
var list1 : List[Int] = new ArrayList[Int]
was really meant to read
var list1 : ArrayList[Int] = new ArrayList[Int]
As written in the text, more than simple type inference is occurring in var list1 : List[Int] = new ArrayList[Int] -- there is also casting. Consequently,
list2 = list1
will produce an error:
error: type mismatch;
found : java.util.List[Int]
required: java.util.ArrayList[Int]
list2 = list1
^
This does not negate the intent of the example, but it does obscure it a bit. In one sense, this example is even more instructive than intended. #48066: It seems that in Generics.scala more is shown than is intended. I suspect that
var list1 : List[Int] = new ArrayList[Int]
was really m ...more...
|
P1.0
28-Nov-11
|
|
| 65 |
|
#41988: Footnote 4. reads: "Equivalent Java code will compile with no errors but result in a runtime ClassCastException."
I think it is not true. Java equivalent will compile and run with no errors. E.g. following code runs without any problems.
List<Integer> list1 = new ArrayList<Integer>();
List list2 = new ArrayList();
list2 = list1;
// this will execute successfully
list2.add("2");
System.out.println(list1);
System.out.println(list2);--Tomasz Wrobel #41988: Footnote 4. reads: "Equivalent Java code will compile with no errors but result in a runtime ClassCastException."
I think it is not true. J ...more...
|
P1.0
03-Jan-10
|
|
| 68 |
|
#39295: "Unfortunately, the way we’re used to is not a idiomatic way to define methods in Scala."
It should be "an idiomatic way". Notice the "an" vs. "a".--Joey Gibson #39295: "Unfortunately, the way we’re used to is not a idiomatic way to define methods in Scala."
It should be "an idiomatic way". Notice the "an" v ...more...
|
B3.0
01-Jun-09
|
|
| 69 |
|
#48068: The code for Methods.scala does not work as expected and produces runtime errors, at least with scala 2.9.1 and IcedTea7 2.0 on Ubuntu.
Specifically, every invocation of printMethodInfo gives something like this:
printMethodInfo("method3")
java.lang.NoSuchMethodException: .method3(null)
at java.lang.Class.getDeclaredMethod(Class.java:1954)
at .printMethodInfo(<console>:9)
at .<init>(<console>:9)
at .<clinit>(<console>)
at .<init>(<console>:11)
at .<clinit>(<console>)
at $print(<console>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.call(IMain.scala:704)
at scala.tools.nsc.interpreter.IMain$Request$$anonfun$14.apply(IMain.scala:920)
at scala.tools.nsc.interpreter.Line$$anonfun$1.apply$mcV$sp(Line.scala:43)
at scala.tools.nsc.io.package$$anon$2.run(package.scala:25)
at java.lang.Thread.run(Thread.java:722)
I have not tried this with any release of Sun/Oracle Java. And I have not tried this with IcedTea 6.
#48068: The code for Methods.scala does not work as expected and produces runtime errors, at least with scala 2.9.1 and IcedTea7 2.0 on Ubuntu.
Spe ...more...
|
P1.0
29-Nov-11
|
|
| 71 |
|
#39631: your where you is appropriate.
"But, your protest, the method is benign."
probably should be...
"But, you protest, the method is benign."--blaine wishart
|
B3.0
23-Jun-09
|
|
| 84 |
|
#40585: The author forgot to include the "var" in front of the repeated "max" example statements. These lines will not execute as written but will after the var is added. JMH
def max2(a: Int, b: Int) : Int = if (a > b) a else b
var max = (Integer.MIN_VALUE /: arr) { (large, elem) => max2(large, elem) }
We are sending the pair of values (large and elem) to the max2( ) method
to determine which of those two is larger. We use the result of that
computation to eventually determine the largest element in the array.
Use the _ to simplify this:
max = (Integer.MIN_VALUE /: arr) { max2(_, _) }
The _ represents not only a single parameter; it can represent the entire
parameter list as well. So, we can modify the call to max2( ) as follows:
max = (Integer.MIN_VALUE /: arr) { max2 _ }
In the previous code, the _ represents the entire parameter list, that is,
(parameter1, parameter2). If you are merely passing what you receive to
an underlying method, you don’t even need the ceremony of the _. We
can further simplify the previous code:
max = (Integer.MIN_VALUE /: arr) { max2 }--John Hyaduck #40585: The author forgot to include the "var" in front of the repeated "max" example statements. These lines will not execute as written but will af ...more...
|
P1.0
28-Aug-09
|
|
| 88 |
|
#39613: "instance given tous" -> "instance given to us"--Kai Virkki
|
B3.0
23-Jun-09
|
|
| 90 |
|
#39614: "in the code previous" -> "in the previous code"--Kai Virkki
|
B3.0
23-Jun-09
|
|
| 94 |
|
#39615: When testing the code examples I noticed that you have to be extra careful to leave an empty line after "def helpAsFriend(friend: Friend) = friend listen", otherwise you have to use the format "friend.listen" or get error "wrong number of arguments for method listen: ()Unit".
--Kai Virkki #39615: When testing the code examples I noticed that you have to be extra careful to leave an empty line after "def helpAsFriend(friend: Friend) = fr ...more...
|
B3.0
23-Jun-09
|
|
| 97 |
|
#46231: The employment application example creates a value with a name of "emplomentApplication". There is a missing Y in this name.
|
P1.0
13-Jan-11
|
|
| 98 |
|
#39616: "val emplomentApplication" -> "val employmentApplication"--Kai Virkki
|
B3.0
23-Jun-09
|
|
| 111 |
|
#42111: The Scala alternate method for foldRight is actually :\ and not \: as written.--rboyd
|
P1.0
19-Jan-10
|
|
|
111 |
#41932: 'plus the literal "done."' -> 'plus the literal "done".'
'does not match "done," then' -> 'does not match "done", then'--Jan Voges
|
P1.0
27-Dec-09
|
|
|
118 |
#41933: "SYMBOL:PRICE." -> "SYMBOL:PRICE".
--Jan Voges
|
P1.0
27-Dec-09
|
|
|
119 |
#41934: "SYMBOL:PRICE." -> "SYMBOL:PRICE".
A running gag ;-) --Jan Voges
|
P1.0
27-Dec-09
|
|
|
123 |
#41935: "GOOG," -> "GOOG",
The last for today --Jan Voges
|
P1.0
27-Dec-09
|
|
|
135 |
#44002: 10.5: ... about explicitly staring an actor...
should be
... about explicitly starting an actor... --Hans-Peter Keilhofer
|
P1.0
07-Jul-10
|
|
|
139 |
#45003: You write, that if the TIMEOUT object is not pattern matched, an exception is thrown. I have tested this with Scala 2.8.0 and there no exception is thrown. The TIMEOUT object is simply stored in the mailbox, and if it is not pattern matched, then it remains in the mailbox and receiveWithin does not terminate after the specified period.
--Dominik Gruntz #45003: You write, that if the TIMEOUT object is not pattern matched, an exception is thrown. I have tested this with Scala 2.8.0 and there no excepti ...more...
|
P1.0
13-Sep-10
|
|
| 141 |
|
#46239: explicitly staring an actor" should be "explicitly starting an actor
|
P1.0
14-Jan-11
|
|
|
164 |
#46010: Text references java.util.AraryList instead of java.util.ArrayList--Jamie Paulson
|
P1.0
15-Dec-10
|
|
|
170 |
#46011: In the ExpectExample code snippet, the code comment states that "The above exception is wrong", it seems that this should say "The above expectation is wrong".--Jamie Paulson #46011: In the ExpectExample code snippet, the code comment states that "The above exception is wrong", it seems that this should say "The above expec ...more...
|
P1.0
15-Dec-10
|
|
| 197 |
|
#41591: The Code example UsingScala/StockPriceFinder uses java.util.Date().getYear. This method on Date is deprecated and does not return the date in the expected format e.g. 2009 but as year-1900 i.e. 109.
This means that year call to the Yahoo webservice returns as much data as is available. E.g. for AAPL it returns around 15 years of data.
Suggestion would be to use Calendar instead.--Peter Pringle #41591: The Code example UsingScala/StockPriceFinder uses java.util.Date().getYear. This method on Date is deprecated and does not return the date in ...more...
|
P1.0
22-Nov-09
|
|