luke.bace (66) [Avatar] Offline
#1
Please post all errors and corrections in this thread. thanks.
lutzhank (61) [Avatar] Offline
#2
Re: Errors and Corrections
MEAP v4 1.1.3

2nd paragraph after box "Side effects", last sentence
orig: "function (x: Int) => x + 1 to a value type inc..."

My humble suggestion: "function (x: Int) => x + 1 to a value inc ..."
("type ommited")

MEAP v4 2.4
expressions probably switched

Original code:
scala> val configFile = if(useDefault) "custom.txt" else "default.txt"

For me it is easier to read if the "custom.txt" and the "default.txt" are switched to read
scala> val configFile = if(useDefault) "default.txt" else "custom.txt"

MEAP v4 Listing 2.4
orig:
val suffixes = List(
"th", "st", "nd", "rd", "th", "th", "th", "th", "th", th")

missing quotation marks before last th => code will not compile:

fix:
val suffixes = List("th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th")

MEAP v4 First listing in 2.7
orig:
"def rangeMatcher(num:Int) = num match..."

rangeMatcher is later referenced as rangeMatcher1
suggestion: change code to
"def rangeMatcher1(num:Int) = num match..."

MEAP v4 Paragraph after Listing 2.4, 4th Line
orig: "inclusive range (scala.collection.immutable.Inclusive)."

This is "scala.collection.immutable.Range.Inclusive" in Scala 2.8

scala> 10.to(20)
res1: scala.collection.immutable.Range.Inclusive with scala.collection.immutable.Range.ByOne ... // ByOne is a Trait mixed into Inclusive which inherits from Range.

MEAP v4 3.2
Code in "How do you create a setter.." box
orig: "def age _=(..."

typo, redundant blank
suggestion: "def age_=(..."

MEAP v4 paragraph before Listing 3.3
Second sentence starting with "If you run this code,..."

I installed mongo on my system started the server, did run this code and got ... nothing.
As long as I didn't added something there had nothing been printed

I then started mongo (shell) and typed the following:
> use mydb
switched to db mydb
> j={name:"any"}
{ "name" : "any" }
> db.test.save(j)

and did run the code again. Then I got the test and system.indexes shown in the output.


MEAP v4 First paragraph after Listing 3.5
orig: "...without using the . operator."

The "." could easily be overlooked (e.g. on my kindle) and I think it's not an operator but a delimiter (dot) in the Scala syntax.

Therefore suggestion: "...without using the . (Dot) notation"


MEAP v4 3.7
second "Note"
original "Note From Scala 2.8..." suggestion: "Note Since Scala 2.8..."

MEAP v4 3.7.1

1) 3rd paragraph, first sentence
orig: "...it returns an instance of the Person class, and it gets called when you create an instance of a case class."

reasoning: This is only true in the example given. An object of the case class could also be created via "new Person("John", "Smith") an then the apply method is not called.

suggestion: "...it returns an instance of the case class (here Person), and it gets called when you request an instance of a case class without new."

2)3rd paragraph, last sentence
orig: "But because we have more than one, we have to return a tuple of two elements."

reasoning: To be compliant to the use of "case class"
we have to return a pair here, but in general we are not constrained to have the same number of placeholder in the pattern matching as the number of parameter of the primary constructor. e.g.
we could define: def unapply(psmilieerson) = Some(p.firstName, p.lastName, 42)

and call it with p match { case Person(firstName, lastName, code) => println(code)} // which would print 42.

So we do not have to return two.

Therefore suggestion: "But because we have two, a tuple of two elements is returned."


MEAP v4 3.9, 5th paragraph, 4th sentence
orig: "...qualify the protected modifier with class, package, and this."

The qualification is rather class name or package name
Therefore suggestion: "...qualify the protected modifier with class name, package name and this."

MEAP version 4 Tabelle 4.2
"xs.update(x, b) and xs(x) = b" exists only in scala.collection.mutable.SetLike not in scala.collection.Set

MEAP version 4 Tabelle 4.3
"ms.update(k, v) and ms(k) = v " exists only in scala.collection.mutable.MapLike not in scala.collection.Map

MEAP version 4 after Listing 5.1
"You can control this behavior of SBT using % instead of %% ..."
must be
"You can control this behavior of SBT using %% instead of %"


-----------------------------------
changed page ref to section ref.
Message was edited by: lutzhank
zszugyi (14) [Avatar] Offline
#3
Re: Errors and Corrections
MEAP 3//4/2011:

Chapter 8 page 1:
"multi-core processers" - typo
"experience[d] programmers" - typo
"better than existing toolset"
zszugyi (14) [Avatar] Offline
#4
Re: Errors and Corrections
"Too many of [the] details[,] let me clarify"

Chapter 8.1

"... application is [to] use threads"
"un-predictable" -> should be no "-"
"ready[-]to[-]run state"
jonmcauliffe (2) [Avatar] Offline
#5
Re: Errors and Corrections
MEAP V4, Page 51 First reference to the DB Object

object DB {
def apply(underlying: MongDB) = new DB(underlying)
}

Type of underlying should probably be MongoDB
jonmcauliffe (2) [Avatar] Offline
#6
Re: Errors and Corrections
MEAP V4 Page 64

"First, pattern matching reduces lots of boilerplate code when compared to pattern matching."
opendev (1) [Avatar] Offline
#7
Re: Errors and Corrections
Meap Scala in Action version 4.
Page 30:

scala> val newList = 3 :: oldList
newList: List[Int] = List(3, 1, 2)

In this example we’re adding 3 to an existing List containing elements 1 and 2 using the :+ method.
The job of the :+ method is to create a new List with all the existing elements plus the new element
added at the front of the List. To add at the end of the List invoke the :+ method:

scala> val newList = oldList :+ 3
newList: List[Int] = List(1, 2, 3)

The two operators that I underlined should be :: to match the previous example. (The next sentence is fine since it is pointing to the next example which does use the :+ operator).
wombat2k (9) [Avatar] Offline
#8
Re: Errors and Corrections
Page 15
Maybe I'm doing something wrong, but it appears :tree or :t is not available in REPL 2.8.1, even if you switch to :power. It also does not appear in the help, leading me to think it's no longer part of REPL. I tried on MacOS X and Linux.

Message was edited by:
wombat2k
nookatee (5) [Avatar] Offline
#9
Re: Errors and Corrections
page 10:

Having an IDE might not interest some of you because of powerful editing tools like
Emacs and TextMate, but having refactoring support is great, especially when working on a large
codebases.

should either be:

Having an IDE might not interest some of you because of powerful editing tools like
Emacs and TextMate, but having refactoring support is great, especially when working on a large
codebase.

or:

Having an IDE might not interest some of you because of powerful editing tools like
Emacs and TextMate, but having refactoring support is great, especially when working on large
codebases.
nookatee (5) [Avatar] Offline
#10
Re: Errors and Corrections
page 11:

For example, in Scala variables and functions without parameters are accessed same way.

should be:

For example, in Scala variables and functions without parameters are accessed the same way.

or possibly:

For example, in Scala variables and functions without parameters are accessed in the same way.
lutzhank (61) [Avatar] Offline
#11
Re: Errors and Corrections
Meap v6 page numbered.105 (pdf p.109), end of section 5.4.2 second last paragraph:

orig: "Lets save this web.xml under src/webapp/WEB-INF" must be
"Lets save this web.xml under src/main/webapp/WEB-INF".

(this is where sbt searches the web application resources like css or javascript.)
bmatheny (1) [Avatar] Offline
#12
Re: Errors and Corrections
MEAP v6, Chapter 12

Lots of TODO items left. Also:

12.2.2, page 199. Typo. Should be scala.io.Source not scala.io.Souce

12.2.5, page 208. I believe in the third example (a.send { someLongRunningProcess}) you intended for this to be a.sendOff
jweden (43) [Avatar] Offline
#13
v6, Listing 1.1
+ after Unit doesn't work for me.

Unit+):

should be:

Unit):
jweden (43) [Avatar] Offline
#14
v6, Listing 1.7
1. I can't get getLines() to take arguments like your code has.
2. Best to print line count for those of us trying out the code

This code works for me:

val src = scala.io.Source.fromFile(new java.io.File("someFile.txt"))
val count = src.getLines().foldLeft(0) {
(i, line) => i + 1
}
println (count)}
jweden (43) [Avatar] Offline
#15
Re: v6, Listing 1.7
and getLines() in my example doesn't need parenthesis so it can be:

val count = src.getLines.fol...
jweden (43) [Avatar] Offline
#16
v6 page 10
1. Same as my last comment, no arg in getLines
2. Be consistent with Listing 1.1 and fully qualify package name for Source:

class FileAsIterable {
val src = scala.io.Source.fromFile(new File("someFile.txt"))
def iterator = src.getLines()
peterbwest (41) [Avatar] Offline
#17
Re: Errors and Corrections
1.1.3 Scala as functional language
Mutable versus immutable data

An object is called mutable when you can alter the contents of the object if you have a reference to it.
Whereas in the case of an immutable object, the contents of the object can’t be altered if you have a
reference to it.


The above should be a single sentence, separated by either a comma or a semicolon.


P4

The benefits of not having mutability and side effects in functional programs are the programs are much easier...

Should be:

The benefits of not having mutability and side effects in functional programs are that the programs are much easier...

Message was edited by: peterbwest
peterbwest
me.colombiano (1) [Avatar] Offline
#18
Re: Errors and Corrections
MEAP v 6 page 31.

The correct URL to Apache HttpClient is http://hc.apache.org/httpcomponents-client-ga/index.html
jweden (43) [Avatar] Offline
#19
v6, p23
Need to explain that (_.isUpper) can optionally use parenthesis instead of curly braces because is has only one parameter.
jweden (43) [Avatar] Offline
#20
Re: v6, p23
Actually, I think the reason is, as you know, because it is only one expression not because it has one parameter if I am learning correctly.
jweden (43) [Avatar] Offline
#21
v6, p23
def break = new Runtime...

explain why there are no parenthesis or curly braces here around method body.
lutzhank (61) [Avatar] Offline
#22
Re: v6, p23
Meap v6, section 2.2.3, p23 (in the text)

orig: def break = new RuntimeException...
must be
fix: def break = throw new RuntimeException....
(see Listing 2.1 where it is done that way)
jweden (43) [Avatar] Offline
#23
v6, p26 section 2.3
v6, p26 section 2.3. Instead of:

"In this example we're adding 3..."

say:

"In the following example we're adding 3..."

This is because I kept looking for :+ in the code above and not in the code below.

Message was edited by:
jweden
jweden (43) [Avatar] Offline
#24
v6 LIsting 2.6 p34
method findIndexOf in trait SeqLike is deprecated: Use indexWhere(p) instead. This is RestClient.scala in your git repo.

Message was edited by:
jweden
jweden (43) [Avatar] Offline
#25
V6 p36
...result of toArray as a variable-length argument

-- you forgot the "-length", otherwise it is confusing
jweden (43) [Avatar] Offline
#26
p49 section 3.6
remove "is":

MongoDB documents are saved in a
collection, and a database is consists of multiple collections.
jweden (43) [Avatar] Offline
#27
Listing 3.5, page 50
You state: "One more thing to note here is that we’re invoking the findOne or getCount method on the underlying collection without using the . operator"

Explain why. Something like: "Functions with zero or one arguments can be called without the dot and parentheses. (And remember that if the function is defined without parentheses, then the function must be called without parentheses.)"

Also you then state, "In Scala, you can invoke methods like the infix
operator (+, -, and so on).". Though true, this sentence seems out of place and not related to anything here unless I am missing something. I think this sentence was meant to be put after Listing 3.6 because of the -= and += function defs.

Message was edited by:
jweden
jweden (43) [Avatar] Offline
#28
Listing 3.10
(Sorry, this is not errata per-se. I'm going through my postings and realizing some of them are not errata and will try to put suggestions in another thread.)

It took me a bit to understand what you are referring to here:

"When it comes to overload methods (methods with the same name), you have to specify the return type; otherwise, the code won’t compile. We have a similar limitation for recursive method calls. Scala type inference can’t infer the type of recursive methods or functions."

Recommend instead:

"When it comes to overloaded methods (methods with the same name), you have to specify the return type; otherwise, the code won’t compile. This is why we specify the DBCursor return type for the find function above. We have a similar limitation for recursive method calls. Scala type inference can’t infer the type of recursive methods or functions which is why we need to specify the DBCursor return type for the applyOptions function above."

Message was edited by:
jweden

Message was edited by:
jweden
jweden (43) [Avatar] Offline
#29
Section 3.9
To make things more clear, change code line from: "trait AngryMood extends DogMood {"

to:

"//WILL NOT COMPILE
trait AngryMood extends DogMood {"
jweden (43) [Avatar] Offline
#30
meap v6 Section 4.1.1.
Change from:

"Maybe the class is a covariant"

to

"The Maybe class is a covariant"
jweden (43) [Avatar] Offline
#31
meap v6 Section 4.1.1.
Scaladoc says these lines you have:

def ++(that: TraversableOnce[A]): Traversable[A]
def ++(that: TraversableOnce[A]): Iterable[A]
def ++(that: TraversableOnce [A]: Seq[A]
def ++(that: TraversableOnce [A]): List[A]

But it is missing the type param in front of the paren:
def ++[A](

Although the scaladoc uses "B" instead of "A" but that doesn't matter too much. Also looking closely at the scaladoc, some of those ++ methods might not exist and List is not a trait. I would double-check the scaladoc

Message was edited by:
jweden
jweden (43) [Avatar] Offline
#32
v6, Section 2.2.3
(Sorry, this is not errata per-se. I'm going through my postings and realizing some of them are not errata and will try to put suggestions in another thread.)

I'm looking at the example here:

def toList[A](value:A) = List(value)

I was confused as to why [A] was used before the parenthesis. After some research, I realized that I didn't really understand Java generic method syntax. I think it would be helpful to include something like:

"The parameterized type syntax for the def line above is similar to the Java generic method syntax where the parameterized type in square brackets -- toList[A] -- is defined after the function name and corresponds to the type of the function's parameter -- value:A"

Message was edited by:
jweden

Message was edited by:
jweden
jweden (43) [Avatar] Offline
#33
v6 section 4.1.1
(Sorry, this is not errata per-se. I'm going through my postings and realizing some of them are not errata and will try to put suggestions in another thread.)

You state: "This is all possible because Traversable is defined with a covariant type parameter."

An example following it would be nice like showing the Traversable class declaration:

trait Traversable[+A] extends scala.collection.Traversable[A]
with GenericTraversableTemplate[A, Traversable]
with TraversableLike[A, Traversable[A]]
with Immutable

Message was edited by:
jweden
jweden (43) [Avatar] Offline
#34
v6 Meap section 4.1.1
You write: "Notice that when you declare an invariant type, you have to drop - or + is missing"

should be:

"Notice that when you declare an invariant type, you have to drop the - or + sign."
jweden (43) [Avatar] Offline
#35
v6 section 4.1.1
You talk about T <: A and T >: A, however you aren't following the Scala convention you mentioned earlier about parameterized types going from A to Z like you show in Listing 4.2.

Instead use: B <: A and B >: A
jweden (43) [Avatar] Offline
#36
v6 section 4.1.1
I really struggled with this section. Let's see if I can capture some more things that I haven't already.

1. trait Function1[-P, +R] { ... } -- this seems like a digression. Instead a full example of contravariance is needed.

2. I was confused as to why a supertype wasn't being passed to getorElse and then I discovered this footnote in Programming in Scala "Supertype and subtype relationships are reflexive, which means a type is both a supertype and a subtype of itself". Since the examples provided are passing showing this reflexive nature rather than using an actual supertype, this HAS to be mentioned.

3. You have a function being passed to getorElse:

def getOrElse[B >: A](default: => B): B = {

though this is valid, I was very confused as to how "-1" can be passed into getorElse as shown in your example. I guess "-1" is considered a function by Scala. It would be a lot clearer if a function was not used as in:

def getOrElse[B >: A](default: B): B = {

This still works.

4. You state:

"we had to set the lower bound to A to satisfy the contravariant rule."

Didn't you mean covariant? And also what rule? Maybe instead you could say something like:

"Because we need to use a covariant type for the default parameter in the getorElse method, we had to get around that by setting the lower bound to A"

5. Mutable objects need to be invariant -- this is that separate gray section. However this is right in the middle of an example. Suggest better placement such as at the end of the chapter after covariance and contravariance are already discussed.
jweden (43) [Avatar] Offline
#37
v6 section 4.2.1
(Sorry, this is not errata per-se. I'm going through my postings and realizing some of them are not errata and will try to put suggestions in another thread.)

Multiple suggestions here:

1. Suggest actually showing a simple implementation of foldRight before showing how it can be used for map2 and flatten2. You have a nice example of foldLeft but it is later. Maybe you want examples of foldLeft and foldRight at the beginning of this section and then get into the more complicated map2 and flatten2.

2. Recommend more explanatory example of flatten2 like:
def flatten2[B](xss: List[List[B]]): List[B] = {
val startValue = List[B]()
xss.foldRight(startValue) { (a,b) =>
println("Prepending List passed in as a: " + a)
println("To List passed in as b: " + b)
val result = a:::b
println("Resulting List is: "+result)
result}
}

flatten2(List(List("one"), List("two")))

Result:

Prepending List passed in as a: List(two)
To List passed in as b: List()
Resulting List is: List(two)
Prepending List passed in as a: List(one)
To List passed in as b: List(two)
Resulting List is: List(one, two)

3. Mention that foldLeft and foldRight both would work for the flatten2 implementation.

Message was edited by: Jason Weden
jweden

Message was edited by:
jweden
jweden (43) [Avatar] Offline
#38
v6 section 4.2.1
(Sorry, this is not errata per-se. I'm going through my postings and realizing some of them are not errata and will try to put suggestions in another thread.)

Recommend showing implementation of map2 and flatten2:

map2(List(1,2,3)){_ + 1}
res3: List[Int] = List(2, 3, 4)

flatten2(List(List("one", "two"), List("three", "four"), List("five", "six")))
res1: List[java.lang.String] = List(one, two, three, four, five, six)

Message was edited by:
jweden
jweden (43) [Avatar] Offline
#39
v6 Section 4.2
(Sorry, this is not errata per-se. I'm going through my postings and realizing some of them are not errata and will try to put suggestions in another thread.)

You write:

Here we’re using the ::: method that appends the
contents of one List to another List.

Suggest a little better:

Here we’re using the ::: method that results in a new list by prepending the
contents of the List on the left of the ::: to the List on the right of :::.

Message was edited by:
jweden

Message was edited by:
jweden
jweden (43) [Avatar] Offline
#40
v7 Section Why Use WithFilter and not Filter?
val list = List(1, 2, 3)
var go = true
val x = for(I <- list; if(go)) yield {
go = false
i
}
println(x)

-- Should be lowercase "i"
jweden (43) [Avatar] Offline
#41
v7 Section 5.3.1 and 5.3.2
When I ran sbt for the first time on my Windows box, it downloaded a bunch of stuff:

C:Usersjweden.IRONMTN>sbt

C:Usersjweden.IRONMTN>set SCRIPT_DIR=C:sbt\r

C:Usersjweden.IRONMTN>java -Xmx512M -jar "C:sbtsbt-launch.jar"
Getting net.java.dev.jna jna 3.2.3 ...
downloading http://repo1.maven.org/maven2/net/java/dev/jna/jna/3.2.3/jna-3.2.3.j
ar ...
[SUCCESSFUL ] net.java.dev.jna#jna;3.2.3!jna.jar (2704ms)
:: retrieving :: org.scala-tools.sbt#boot-app
confs: [default]
1 artifacts copied, 0 already retrieved (838kB/107ms)
Getting Scala 2.9.1 (for sbt)...
downloading http://repo1.maven.org/maven2/org/scala-lang/scala-compiler/2.9.1/sc
ala-compiler-2.9.1.jar ...
[SUCCESSFUL ] org.scala-lang#scala-compiler;2.9.1!scala-compiler.jar (17
488ms)
downloading http://repo1.maven.org/maven2/org/scala-lang/scala-library/2.9.1/sca
la-library-2.9.1.jar ...
[SUCCESSFUL ] org.scala-lang#scala-library;2.9.1!scala-library.jar...

*****OMITTING lots here*******

and then at the end it states:

[info] Done updating.
[info] Set current project to default-625dab (in build file:/C:/Users/jweden.IRO
NMTN/)
>

I also see the last part above when I type exit and then sbt again. This is not a yes/no question and just, as I understand, is sbt interactive mode at which I can type exit. The current project -- without me doing anything -- seems to have been pre-named and set in my home directory. This all seems by-design and differs greatly from how you describe the first-time run in section 5.3.1. And the beginning part of section 5.3.2 where you create a project and type "actions" and hit enter also is wrong. The references to scala versions and the google page are outdated since sbt has moved to github.

To get hello_world.scala program going I had to create my own top-level directory, put in a blank build.sbt, create src/main/scala and src/test/scala and start sbt in said top-level directory. However, I first tried to get the separate scala new-project plugin going to short-circuit these steps, but I could not get it going: https://github.com/softprops/np

Instead of using SimpleProjectDefinition.scala put the following in a build.sbt file in top-level project directory:

name := "My Project"

mainClass in (Compile, run) := Some("HelloWorld")

Message was edited by:
jweden
jweden (43) [Avatar] Offline
#42
v7 Section 5.3.3
Here is what I used to get jetty going in sbt:

Follow plugin directions here:

https://github.com/siasia/xsbt-web-plugin/wiki/

My build.sbt looks like this for my scala 2.9.1 version:

name := "weKanban"

seq(webSettings :_*)


libraryDependencies ++= Seq(
"org.eclipse.jetty" % "jetty-webapp" % "8.0.3.v20111011" % "container",
"javax.servlet" % "servlet-api" % "2.5" % "provided->default"
)

//Notice new namespace for compatible version of scalaz
libraryDependencies += "org.scalaz" % "scalaz-full_2.9.1" % "6.0.3"

//libraryDependencies += "com.googlecode.scalaz" % "scalaz-http_2.8.0" % "5.0"

libraryDependencies += "com.h2database" % "h2" % "1.2.137"

libraryDependencies += "org.squeryl" % "squeryl_2.9.1" % "0.9.4"

--I used "container:start" sbt command. Not sure if any of this right..we'll see...but I can do an sbt update and sbt compile with your github code copied from chapter 5 src directory.

Message was edited by:
jweden

Message was edited by:
jweden
jweden (43) [Avatar] Offline
#43
v7 Another example of Higher-kinded type - no underscore?
Oddly I don't see the underscore in between the brackets when I look at the pdf:

def sum[F[ ], A](xs: F[A]...

but when I do a copy and paste, I do see it:

def sum[F[_], A](xs: F[A]...

So I don't know if this is a typo, a pdf formatting issue, or something going on in my pdf reader.
robr@fastq.com (1) [Avatar] Offline
#44
Re: Errors and Corrections
Just this minute bought the book 2011-12-22 -- (first time posting errata ( or my perception thereof!))
Pg 2 : 1.+2 is not a method on an Integer, but is on a Double.
Pg 3: "... neither objects nor procedures ... but functions"
Since functions are objects in Scala ( as best I can understand ) maybe a rewording?
cheers
rob rucker
seltzerlj (13) [Avatar] Offline
#45
Re: Errors and Corrections
(1)
Chapter 5's title,
"Building web application in functional style"

should be

"Building web applications in functional style"

(2)
On page 121, the 4th bulleted item,
"Creating an web application in Scala called weKanban"

should be

"Creating a web application in Scala called weKanban"

(3)
Also on page 121,
"In this second part of the book we will switch our focus on more real world application of Scala programming language"

should be

"In this second part of the book we will switch our focus to more real world applications of the Scala programming language"

This is the first time I've looked at the book. I imagine there are many more errors similar (basic English grammar) to the above, so the book should be thoroughly proofread before publication!

Thanks.
roterl (4) [Avatar] Offline
#46
Re: Errors and Corrections
MEAP v8, Page 157
class Story {
...
def save(): Either[Throwable, String] = {
tx {
try {

validate
stories.insert(this)
Right("Story is created successfully")
} catch {
case exception => Left(exception)
}
}
...
}


the try block is inside the tx block - this mean the tx will never have exception, anf therefor will not roleback.
the tx block should be inside the try block.

Simple test can be done by adding save of another Story before the validation:
def save(): Either[Throwable, String] = {
try {
tx {

stories.insert(Story("999", "before validation"))
validate
stories.insert(this)
Right("Story is created successfully")
}
} catch {
case exception => Left(exception)
}
}


when this code is executed while the validation failed the Story "999" should be roleback too.

Rotem.
bhericher (31) [Avatar] Offline
#47
Re: Errors and Corrections
MEAP V8

Section 2.1 page 21

"TIP println is a functon" should be "TIP println is a function"

Message was edited by:
bhericher
aramirez (2) [Avatar] Offline
#48
Re: Errors and Corrections
Meap v8, page 32, 2nd paragraph

"...into Scaladoc for scala.collection.mutable.ArrayLike. The most obvious question
that’s coming to your mind right [now] is probably why we have to check ArrayLike, which is a..."
aramirez (2) [Avatar] Offline
#49
Re: Errors and Corrections
MEAP v8, Page 38, Section 2.4

Code example logic is wrong:

val someValue = if(some condition) value1 else value2
scala> val useDefault = false
useDefault: Boolean = false
scala> val configFile = if(useDefault) "custom.txt" else "default.txt"
configFile: java.lang.String = default.txt


if useDefault is set to false, the val should not be default.txt

-Aaron
peterbwest (41) [Avatar] Offline
#50
Re: Errors and Corrections
V9 Page 21
A corner case with floating literals
In floating literals you could define a double value as 1.0 or simply as 1, without the trailing zero or digits.

Should be:
...a double value as 1.0 or simply as 1.,

Note the decimal point after the second "1".
peterbwest (41) [Avatar] Offline
#51
Re: Errors and Corrections
V9

Figure 2.1
method body within parenthesis
should be
method body within parenthesis
seltzerlj (13) [Avatar] Offline
#52
Re: Errors and Corrections
On page 5, PDF edition:

Mondadic effects (chapter 10)

should be

Monadic effects (chapter 10)
eremmel (14) [Avatar] Offline
#53
Re: v6, p26 section 2.3
v10,p38 section 2.3 (near top of page)
The "In this example" does refer to the previous section, because the author talks about "added to the front of the List", then the author switches to adding data to the end of the list.
So the error is that author mentions in the first two sentence ":+", but it should be "::". Only the third ":+" is correct.
cjclz (2) [Avatar] Offline
#54
Re: Errors and Corrections
MEAP v10
page 38

In this example we’re adding 3 to an existing List containing elements 1 and 2 using the :+ method. The job of the :+ method is to create a new List with all the existing elements plus the new element added at the front of the List. To add at the end of the
List invoke the :+ method:

Correction:
first line should be "... using the :: method. The job of the :: method is to ..."
cjclz (2) [Avatar] Offline
#55
Re: Errors and Corrections
MEAP v10
page 39

In the first code sample:
val files = new java.io.File("."smilie.listFiles for(file <- files) {
val filename = file.getName
if(fileName.endsWith(".scala")) println(file)
}

The value filename is in a different case, resulting in the error:
error: not found: value fileName
if(fileName.endsWith(".scala")) println(file)
deleteonexit (1) [Avatar] Offline
#56
p23 hexa - octa
scala> val hexa = 0x23
hexa: Int = 35

scala> val octa = 023
octa: Int = 19

That last variable was incorrectly shown as "hexa" when it should be "octa"
wolfgangp (1) [Avatar] Offline
#57
Re: Errors and Corrections
Page 96 at the bottom

Object[] arr = new int[1];

should be

Object[] arr = new Integer[1];

Attempting to assign a reference to an array of a primitive type to an array of objects results in a compile time error.
rickg (16) [Avatar] Offline
#58
Re: Errors and Corrections
I notice in Section 2.3 the following:

The job of the :+ method is to create a new List with all the existing
elements plus the new element added at the front of the List. To add at the end of the
List invoke the :+ method

I believe you mean the first sentence to describe the job of :: don't you?

Sorry if this has already been mentioned. I searched.
GavinBaumanis (10) [Avatar] Offline
#59
Re: Errors and Corrections
Page 4:
1.1.2 Scala as functional language

Before I describe Scala as functional language, you need to understand what is functional
programming if you not familiar with it.

Consider;
Before I describe Scala as a functional language, you need to understand what is functional programming.
javendo (3) [Avatar] Offline
#60
Re: Errors and Corrections
In the session 5.3.1, the command:

Java -Xmx512M -jar `dirname $0`/sbt-launch-0.7.4.jar "$@"

Would be written with the lowercase J instead of the uppercase one. I think there is some automatic tool that change all the first character in a paragraph to uppercase. This kind of thing needs to be reviewed.
santoshgokak (8) [Avatar] Offline
#61
Re: Errors and Corrections
Page 84, the side bar reads "First, pattern matching reduces lots of boilerplate code when compared to pattern matching.". i think it should be "First, pattern matching reduces lots of boilerplate code when compared to Visitor Pattern".
retomatter (1) [Avatar] Offline
#62
Re: Errors and Corrections
MEAP v12

8.2.1 Structural types

on page 235:

type Closable = { def close: Unit }
def close(closable: { def close: Unit }) = {
closable.close
}

should probably read

type Closable = { def close: Unit }
def close(closable: Closable) = {
closable.close
}
Brian Topping (22) [Avatar] Offline
#63
Re: Errors and Corrections
Figure 12.9 needs to be reconciled with the text; one uses "monitor" and the other uses "supervisor".
BradleySCollins (7) [Avatar] Offline
#64
Re: Errors and Corrections
In MEAP v12 on page 14, Listing 1.5 reads as follows:

class Programmer(var name:String,var language:String,var favDrink:String

It should be corrected to add the missing closing parenthesis:

class Programmer(var name:String,var language:String,var favDrink:String)
BradleySCollins (7) [Avatar] Offline
#65
Re: Errors and Corrections
In MEAP v12 on page 36, the first paragraph begins:

When writing Scala scripts, you sometimes have to take command-like arguments.

It should be corrected to read:

When writing Scala scripts, you sometimes have to take command-line arguments.
BradleySCollins (7) [Avatar] Offline
#66
Re: Errors and Corrections
In MEAP v13, Listing 2.6 on p. 49 and Listing 2.9 on p. 52 still contain the following line:

val index = args.findIndexOf(_ == paramName)

@jwedon previously pointed out, "method findIndexOf in trait SeqLike is deprecated: Use indexWhere(p) instead. This is RestClient.scala in your git repo."

Apparently findIndexOf is not only deprecated in Scala 2.10, but completely gone so that this script does not work.
Springfield (4) [Avatar] Offline
#67
Re: Errors and Corrections
Page 14. The definition of the Programmer class in Scala is an incomplete statement.
I suggest adding the close paren and semi-colon as in -->
"class Programmer (var name:String, var language:String, var favDrink:String);"

Cheers.
Springfield (4) [Avatar] Offline
#68
Re: Errors and Corrections
Chapter 2 Section 2.2 --> "you can use any of the development environments mentioned in the previous section that suit you."

There are no specific development environments mentioned either in the previous section or even in the prior chapter that I can find. I've searched on various keywords (IDE, environment, development) and have not found any references.

Cheers.

Message was edited by:
Springfield
Springfield (4) [Avatar] Offline
#69
Re: Errors and Corrections
Page 43: "In Java you can only use a switch statement with primitives and enums"....
This statement is no longer true... as of Java SE 7 Strings can be used to control switch statements.

Cheers.
BradleySCollins (7) [Avatar] Offline
#70
Re: Errors and Corrections
In Scala_in_Action_v14_PUBLISH.pdf on p. 90, the following function appears to return the wrong type:

implicit def int2RangeMaker(left: Int): Range = new RangeMaker(left)


The correct code should apparently be:

implicit def int2RangeMaker(left: Int): RangeMaker = new RangeMaker(left)
zenwork (1) [Avatar] Offline
#71
Re: Errors and Corrections
Listing 2.6 on page 49:

is:

     val index = args.findIndexOf(_ == paramName)

should be:

     val index = args.indexWhere(_ == paramName)
scalkyo (1) [Avatar] Offline
#72
Re: Errors and Corrections
In the acknowledgements page VI Martin Odersky is spelt as Ordesky.
MarkElston (10) [Avatar] Offline
#73
Re: Errors and Corrections
On page 140 in the paragraph before section 5.3 it says

... and the ResourceLocator is a function that takes the name...

I think that it should be:

... and ioResourceLocator is a function that takes the name ...
nidkil (2) [Avatar] Offline
#74
Re: Errors and Corrections
Page 39, paragraph 2.5 example:

The variable "fileName" should be "filename".
nidkil (2) [Avatar] Offline
#75
Re: Errors and Corrections
Page 47 code example:

"paramaters(request)" should be "parameters(request)".