Deal of the Day

Home » Main » Manning Forums » 2010 » Scala in Action

Thread: Errors and Corrections

Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 74 - Pages: 5 [ Previous | 1 2 3 4 5 | Next ] - Last Post: Oct 7, 2014 9:09 AM by: nidkil
jweden


Posts: 43
Registered: 8/26/09
v6 page 10
Posted: Aug 24, 2011 9:05 AM   in response to: luke.bace in response to: luke.bace
  Click to reply to this thread Reply

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

Posts: 41
From: Brisbane
Registered: 11/30/10
Re: Errors and Corrections
Posted: Aug 24, 2011 5:13 PM   in response to: luke.bace in response to: luke.bace
  Click to reply to this thread Reply

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

Posts: 1
From: Colombia
Registered: 8/27/11
Re: Errors and Corrections
Posted: Aug 27, 2011 9:06 PM   in response to: luke.bace in response to: luke.bace
  Click to reply to this thread Reply

MEAP v 6 page 31.

The correct URL to Apache HttpClient is http://hc.apache.org/httpcomponents-client-ga/index.html

jweden


Posts: 43
Registered: 8/26/09
v6, p23
Posted: Sep 4, 2011 8:28 AM   in response to: luke.bace in response to: luke.bace
  Click to reply to this thread Reply

Need to explain that (_.isUpper) can optionally use parenthesis instead of curly braces because is has only one parameter.

jweden


Posts: 43
Registered: 8/26/09
Re: v6, p23
Posted: Sep 4, 2011 9:24 AM   in response to: jweden in response to: jweden
  Click to reply to this thread Reply

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


Posts: 43
Registered: 8/26/09
v6, p23
Posted: Sep 4, 2011 9:30 AM   in response to: luke.bace in response to: luke.bace
  Click to reply to this thread Reply

def break = new Runtime...

explain why there are no parenthesis or curly braces here around method body.

lutzhank


Posts: 62
Registered: 11/15/10
Re: v6, p23
Posted: Sep 4, 2011 3:26 PM   in response to: jweden in response to: jweden
  Click to reply to this thread Reply

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


Posts: 43
Registered: 8/26/09
v6, p26 section 2.3
Posted: Sep 4, 2011 4:49 PM   in response to: luke.bace in response to: luke.bace
  Click to reply to this thread Reply

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


Posts: 43
Registered: 8/26/09
v6 LIsting 2.6 p34
Posted: Sep 10, 2011 11:27 AM   in response to: luke.bace in response to: luke.bace
  Click to reply to this thread Reply

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


Posts: 43
Registered: 8/26/09
V6 p36
Posted: Sep 14, 2011 8:39 PM   in response to: luke.bace in response to: luke.bace
  Click to reply to this thread Reply

...result of toArray as a variable-length argument

-- you forgot the "-length", otherwise it is confusing

jweden


Posts: 43
Registered: 8/26/09
p49 section 3.6
Posted: Sep 19, 2011 9:40 AM   in response to: luke.bace in response to: luke.bace
  Click to reply to this thread Reply

remove "is":

MongoDB documents are saved in a
collection, and a database is consists of multiple collections.

jweden


Posts: 43
Registered: 8/26/09
Listing 3.5, page 50
Posted: Sep 19, 2011 9:49 AM   in response to: luke.bace in response to: luke.bace
  Click to reply to this thread Reply

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


Posts: 43
Registered: 8/26/09
Listing 3.10
Posted: Sep 21, 2011 1:33 PM   in response to: luke.bace in response to: luke.bace
  Click to reply to this thread Reply

(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


Posts: 43
Registered: 8/26/09
Section 3.9
Posted: Sep 21, 2011 2:55 PM   in response to: luke.bace in response to: luke.bace
  Click to reply to this thread Reply

To make things more clear, change code line from: "trait AngryMood extends DogMood {"

to:

"//WILL NOT COMPILE
trait AngryMood extends DogMood {"

jweden


Posts: 43
Registered: 8/26/09
meap v6 Section 4.1.1.
Posted: Sep 23, 2011 8:24 AM   in response to: luke.bace in response to: luke.bace
  Click to reply to this thread Reply

Change from:

"Maybe the class is a covariant"

to

"The Maybe class is a covariant"

Legend
Gold: 300 + pts
Silver: 100 - 299 pts
Bronze: 25 - 99 pts
Manning Author
Manning Staff
Manning Developmental Editor