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

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...more...

Reported in:
P1.0
(11-Nov-11)

#47936PDF page: 40

The words "do for" in the code snippet is overstriked. Is that a typo?--Kirin

Reported in:
P1.0
(01-Nov-09)

#41155PDF page: 49

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

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 ...more...

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.

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 sce...more...

Reported in:
P1.0
(28-Nov-11)

#48066PDF page: 64

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.

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 ...more...

Reported in:
P1.0
(03-Jan-10)

#41988PDF page: 65

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;

Footnote 4. reads: "Equivalent Java code will compile with no errors but result in a runtime ClassCastException."
I think it is not true. Java equi...more...

Reported in:
B3.0
(01-Jun-09)

#39295PDF page: 68

"Unfortunately, the way we’re used to is not a idiomatic way to deﬁne methods in Scala."

It should be "an idiomatic way". Notice the "an" vs. "a".--Joey Gibson

"Unfortunately, the way we’re used to is not a idiomatic way to deﬁne methods in Scala."
It should be "an idiomatic way". Notice the "an" vs. "a".-...more...

Reported in:
P1.0
(29-Nov-11)

#48068PDF page: 69

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.

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.
Specificall...more...

Reported in:
B3.0
(23-Jun-09)

#39631PDF page: 71

your where you is appropriate.
"But, your protest, the method is benign."
probably should be...
"But, you protest, the method is benign."--blaine wishart

your where you is appropriate.
"But, your protest, the method is benign."
probably should be...
"But, you protest, the method is benign."--blaine w...more...

Reported in:
P1.0
(28-Aug-09)

#40585PDF page: 84

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

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 ...more...

Reported in:
B3.0
(23-Jun-09)

#39613PDF page: 88

"instance given tous" -> "instance given to us"--Kai Virkki

Reported in:
B3.0
(23-Jun-09)

#39614PDF page: 90

"in the code previous" -> "in the previous code"--Kai Virkki

Reported in:
B3.0
(23-Jun-09)

#39615PDF page: 94

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

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 lis...more...

Reported in:
P1.0
(13-Jan-11)

#46231PDF page: 97

The employment application example creates a value with a name of "emplomentApplication". There is a missing Y in this name.

Reported in:
B3.0
(23-Jun-09)

#39616PDF page: 98

"val emplomentApplication" -> "val employmentApplication"--Kai Virkki

Reported in:
P1.0
(19-Jan-10)

#42111PDF page: 111

The Scala alternate method for foldRight is actually :\ and not \: as written.--rboyd

mailboxSize is never not 0. As I'm still learning Scala, I'm not quite able to figure out why from the source though given this book is now 4+ years old, things may have changes here.--Rob S.

mailboxSize is never not 0. As I'm still learning Scala, I'm not quite able to figure out why from the source though given this book is now 4+ years ...more...

Reported in:
P1.0
(07-Jul-10)

#44002Paper page: 135

10.5: ... about explicitly staring an actor...
should be
... about explicitly starting an actor... --Hans-Peter Keilhofer

Reported in:
P1.0
(13-Sep-10)

#45003Paper page: 139

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

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 th...more...

Reported in:
P1.0
(14-Jan-11)

#46239PDF page: 141

explicitly staring an actor" should be "explicitly starting an actor

Reported in:
P1.0
(28-Dec-12)

#50418PDF page: 141

"You can restart the actor, if you like, by calling the start( ) method." - This is not possible.--Robert Slifka