By Developers, For Developers

Historical errata for Groovy Recipes

PDF PgPaper PgTypeDescriptionFixed onComments
4444TYPO

global warning should be global warming

2008-04-21
109ERROR

In Appending data to an existing file
this code (before and after the append)
println “${file.size()} lines”

should be

println “${file.readLines().size()} lines ”

2008-04-21
25TYPO

$groovy -version did not work (using version 1.5.4)
Had to use
$groovy -v
or
$groovy —version

2008-04-21
84TYPO

java.io.tmp property doesn’t exist. Should be java.io.tmpdir instead.

19TYPO

The paragraph at the bottom of page 19 that starts with ‘The“blue pill”…’ is missing a space between ‘The’ and ‘"blue’. Very minor.

212TYPO

On section 11.8 in the explanation of the code for the BookController, the text mentions the call to the controller “Bookstore.list” and it should be “BookController.list” which then maps to “book.list”.

121SUGGEST

The last sentence of the second paragraph says, “Therefore, you must trap for it explicitly:” but I thing it should be “Therefore, you must ask for it explicitly:”

122TYPO

The first (only) sentence of second paragraph says, “… your query results can end up being looking like nonsense …” and I strongly suspect it should be “… your query results can end up looking like nonsense …”

126TYPO

There’s a space missing between the end of the first sentence on the page and the start of the second. “… construct a valid GroovyBean from XML.pxml.children() returns a list …” should be “… construct a valid GroovyBean from XML. pxml.children() returns a list …”

152SUGGEST

The last sentence in the “Building the Query String from a Map” section refers the reader to Section 9.4, “Creating a Convenience QueryString Class” which happens to be the very next thing on the page.
While it is consistent with the way all other references are made in the book, it seemed very odd when I first read it.

185TYPO

Last sentence of the first paragraph says, “It can yield unpredictable results if the getter or setter is doing anything other than directly setting the value of the attribute.” Maybe this should be something like “It can yield unpredictable results if the getter or setter are doing anything other than directly getting or setting the value of the attribute.”
It’s not perfect, but the phrases “getter or setter” and “getting or setting” imply that the getter gets and the setter sets, so it may be a bit more clear.

222TYPO

Last sentence in the first paragraph says, “The value that appears in the combo box is the toString method.”
Perhaps this should be “The value that appears in the combo box is from the toString method of the Publisher class.”

228TYPO

The first sentence of the last paragraph in the “Render as XML” section says, “In this example, we’ll leave off the parentheses on the render method …”
I think it makes more sense to use the phrasing in the “Render as JSON” section on pg 230; “In this example, we’re leaving off the parentheses …” since the text follows the code in question so you’ve already left the parens off.

236TYPO

The first (and only) paragraph on the page is composed of the same five sentences twice.

0TYPO

This issue is on many of the pages in the book (17, 18, 19, … 181, 203) and is more nit-picky but I noticed that in many (but not all) of the output examples, java key words are in bold-face - as if the output text was being parsed as source code.

52TYPO

In the first example of the “Safe Dereferencing” section, the output of s.size() should be 4 not 5.

121TYPO

First sentence. “You still want to know how XmlParser…” should be “You still want to know how XmlSlurper…”

36TYPO

3.4 Optional Return Statements
“global warning” instead of “global warming”

196TYPO

In the third paragraph, “.bash_rc” should be “.bashrc” (Book version 2008-04-23, P2.0 printing, April 2008. P2.0 was NOT an option in the web form to submit this Erratum.)

54ERROR

// I’m using Groovy Version: 1.7.1 JVM: 1.6.0_18
// this doesn’t remove any items from the map
// family.remove always returns null when using the GString
// I can print ${k} out and it looks right,
// but it doesn’t work in the statement, below:
kids.each{ k,v -> family.remove(“${k}”) }

// using k in place of the GString works
kids.each{ k,v -> family.remove(k) }

// Here’s a GroovyConsole listing
groovy> // Map Shortcuts
groovy> // Concatonating Example on Page 54
groovy> def family = [dad:“john”, mom:“jane”]
groovy> def kids = [kid1:“timmy”, kid2:“susie”]
groovy> println family += kids
groovy> kids.each{k,v ->
groovy> println family.remove(“${k}”);
groovy> }
groovy> println family

[dad:john, mom:jane, kid1:timmy, kid2:susie]
null
null
[dad:john, mom:jane, kid1:timmy, kid2:susie]

Categories: