By Developers, For Developers

Historical errata for Programming Groovy

PDF PgPaper PgTypeDescriptionFixed onComments
3TYPO

“languages allow you to do things at runtime that static languages do at
compile tim;”

The ‘e’ is missing from time. (This was the preview PDF)

2008-02-21
9TYPO

Replace “compile tim;” with “compile time;”

2008-02-21
12TYPO

Para 1:

“(where the richness is really today)” should read “(where the richness really is today)” or similar.

2008-02-21
14SUGGEST

Para 4:

your work done. Groovy first provides you that. It further extends the JDK with convenience methods and closure support through the GDK

This may read more easily as:

As a Java programmer, you rely heavily on the JDK and its APIs to get your work done. These are still available in Groovy. In addition, Groovy extends the JDK with convenience methods and closure support through the Groovy Development Kit, or GDK.

2008-02-21
19SUGGEST

You have no description of how to install on Linux or Unix (Solaris, etc). Of course, this is almost identical to the Mac.

Also, would it not be more common to install as /opt/groovy ? One might then have a symlink from /usr/local/bin/groovy -> /opt/groovy/bin/groovy, but you probably wouldn’t want to put the entire install tree under /usr/local/bin, right?

2008-02-21
24TYPO

staticmain() should be “static main()” (including space)

2008-02-21
24TYPO

“that takes String()” -> “that takes String[]” or “String[] array”

2008-02-21
26TYPO

YOu also have

Should have “You”

2008-02-21
27SUGGEST

Section 2.5 is confusing.

In the 1st listing of Script1a, it is not clear why name is set after the println. You should first show the modified calling script (Script2a?) that passes the parameter name and receives the modified name variable.

The calling script is never listed.

2008-02-21
51ERROR

The output from the Calendar “plus” example is not shown. Instead, the source code is repeated.

When you put in the example, be sure to specify the current date on which is was run!

2008-02-21
53TYPO

Footnote 9 seems to be incomplete

2008-02-21
56SUGGEST

I don’t understand the phrase “pay our technical debt” ???

2008-02-21
58SUGGEST

“instance created is [I, which is the JVM representation for int[].”

Your typesetting in the PDF files makes the square brackets “[]” appear to be round parentheses “()” in the normal text (they do appear correctly in the code fragments, though). Is there some way to fix this?

I am viewing using KPDF 0.5.4 on RHEL 5.1

2008-02-21
64SUGGEST

“If you tune the dial up, ” ??? Do you mean something like “If you turn up the volume” ? If so, it might be better phrased “If you listen closely, …”

2008-02-21
71TYPO

Source code for takeHelpAndReward() is shown, rather than the output

2008-02-21
72SUGGEST

" why I don’t have it in the middle between " should be something like “why doesn’t the figure show it in the middle between …”

2008-02-21
75SUGGEST

“doubled << i 2”

Unless I missed, you’ve not yet covered the << operator for appending to Groovy arrays. This might be confusing to new readers, since you’ve not yet covered collections. You may want to explain what is happening, or use a List.

2008-02-21
77TYPO

“a function with variable bound to a context or environment in which it executes.”

Should this be “with a variable”? Or, it might read better as “a function with a variable bound to a context (the environment in which it executes).”

2008-02-21
79TYPO

On next to last line, missing question mark: “passed in?”

2008-02-21
17TYPO

1.5 - second paragraph

“…learn some tricks and trips of the language…” trips should probably be ‘tips’.

2008-02-21
36TYPO

Section 3.2 - End of first paragraph

“…on to create thousands of silly
method in their applications.” method should probably be plural.

2008-02-21
109TYPO

“out stock price” -> “our stock price”

2008-02-21
109TYPO

xml = “${content}”

should be plural:

xml = “${content}”

2008-02-21
120SUGGEST

“You can use the filterLine( ) method to realize the Unix command grep-like feature.”

This is a bit unclear. A better version would be

“The filterLine() method is similar to the Unix grep command.”

There is also a missing “the” in the 1st sentence of the next paragraph: “looks for any line in the input…”

2008-02-21
129TYPO

consuling -> should be consuming

2008-02-21
9TYPO

1.1 Why Dynamic Languages?
Dynamic Languages have the ability to extend a program at runtime,
including changing the structure of objects, types, and behavior. Dynamic
languages allow you to do things at runtime that static languages do at
compile tim; they allow you to execute program statements that were
created on-the-fly, at runtime.

missing the letter ‘e’ on the end of “compile time” right before the semi-colon.

2008-02-21
29TYPO

2nd para, ref to com.agiledeveloper.Hello.sayHello() exceeds right paragraph margin.

2008-03-19
44TYPO

“Caffeine” is misspelled as “Caffine” in several places.

2008-03-19
46TYPO

Para under “varargs” heading. Odd line break after “Remember,”.

2008-03-19
64TYPO

3rd para from bottom of page:
(1) “What’s the fate of the program when you run?” Run where? Perhaps “when it runs?”, or even “when you run it?”.
(2) “If you tune the dial up”. Use “turn” instead of “tune”.

2008-03-19
66TYPO

2nd para:
(1) “They allow us to agree upon a certain
expectations to be fulfilled.” Change “a certain” to “certain”.
(2) “excel the expectations”. Replace “excel” with “exceed”.

2008-03-19
79TYPO

2nd para from bottom: “We’ve seen how to define and use closures; in this section we will go a bit deeper.” Why not just make this two sentences? “…and use closures. In this…”.

2008-03-19
32TYPO

5th paragraph on page, 3rd sentence begins: “The groovysy command compiles and executes completed statements”

It should probably read “The groovysh command compiles and executes completed statements”

2008-03-19
129TYPO

If you want to perform operations on each element of a collection, use
each( ); however, if you want to collection of the result of such a computation,
use the collect( ) method.

“if you want to collection of the result” is incorrect

2008-03-19
32TYPO

The groovysy command compiles and executes completed statements as soon as you hit the Enter/Return key

Should say groovysh, not groovysy.

2008-03-19
41TYPO

“Raiders of the Lost Arc” should be “Raiders of the Lost Ark” — John Loizeaux

2008-03-19
35SUGGEST

There is a Groovy plugin in the works for NetBeans. It is currently available from the development plugin center.

2008-03-19
173TYPO

Section 11.1, 3rd para - “you can take advantage of the Groovy join-compilation facility” should be “…joint-compilation…”

2008-03-19
109ERROR

Missing: fix reference to figure here

2008-04-29
203ERROR

Missing: Please make the sect2’s in this chapter appear in table of contents—I don’t know how to do that, but I think
these section titles are important to appear in toc

Missing: they should be title 1s then if they’re that important. –CE

2008-04-29
274ERROR

Missing: fix the following xref

2008-04-29
286ERROR

Missing: fix the following xref

2008-04-29
211OK

Integer.metaClass.static.isEven should be
Integer.metaClass.‘static’.isEven

2008-04-29
214OK

System.out.println at bottom of page where the more consistent println could be used

same issue pages 216-221

2008-04-29
41SUGGEST

In comparing Java code to Groovy you use the evocative example of the sword-fight scene from Raiders of the Lost Ark. However your reference to a YouTube video (www.youtube.com/watch?v=m5TcfywPj0E) results in an error; YouTube has removed the video.

However, you can still find it at AOL (video.aol.com/video-detail/indiana-jones-sword-fight/2100620337). Interestingly it is a YouTube video!

2008-04-29
80TYPO

Section 4.4: They allow us to agree upon a certain expectations to be fulfilled.

should read

They allow us to agree upon certain expectations to be fulfilled.

2008-04-29
121OK

The page ends with

…elegant cousin of ’\\\\d\\\\w"

That should be

…elegant cousin of ‘\\\\d\\\\w’

2008-04-29
66TYPO

“Generics.java:10: cannot find symbol” needs to be “Generics.java:11: cannot find symbol” since line 11 is passing a String to the List.

2008-04-29
49TYPO

“leads to a problems” should read, “leads to problems”

162ERROR

The code:
langs = [‘C’ : ‘Stroustrup’ , ‘Java’ : ‘Gosling’ , ‘Lisp’ : ‘McCarthy’ ]
xmlDocument = new groovy.xml.StreamingMarkupBuilder().bind {
mkp.xmlDeclaration()
mkp.declareNamespace(computer: “Computer” )
languages {
comment << “Created using StreamingMarkupBuilder”
langs.each { key, value ->
computer.language(name: key) {
author (value)
}
}
}
}
println xmlDocument

Does not produce an indented xml document, but a single line string. This is really important to mention and confusing. I don’t think there is a way to make the output indented with that Builder.

129ERROR

“Here’s an example: friends refers to a map”

Friends is a list, not a map. Also, the short names in the list definition (e.g. briang) are never used.

202TYPO

4th paragraph, 1st sentence: “…the names of methods you want to add to one more more classes.” The word “more” is repeated twice. I’m guessing the first “more” should really be “or”.

203218SUGGEST

I suggest discussing propertyMissing. I tried using method injection based on chapter 14 for a property and wondered why I was not seeing setXXX() and getXXX() like I expected.

37TYPO

Last paragraph of the page reads: “it leads to a problems, such as when…”

“a problems” is not correct.

37TYPO

According to the context and subsequent
examples etc.

def access(location,weight,fragile)

should be

def access(weight,location,fragile)

76TYPO

The text says “BigNumber” instead of “BigDecimal” in the 2nd paragraph (not that I don’t wish my raise was a BigNumber…)

89TYPO

2nd paragraph: “So, the compiler treats the instance of BigNumber as Number.”

BigNumber should be BigDecimal.

149ERROR

The code works with 1.5.6, JVM: 1.5.0_17-b04 on Ubuntu 8.10
I haven’t found a jvm that works with Groovy 1.5.7. If I use 1.5.7 to run UsingDOMCategory.groovy I get
Caught: java.lang.StackOverflowError

The languages.xml file in the code download differs from the example in the book on page 148. The xml file in the book works fine, but the one in the download returns empty results.

44TYPO

In the table “Type x Condition for truth”, for Iterator, instead of “has text”, it should be “has next”, isn’t it ?

197TYPO

one more more classes -> one more to.

1ERROR

I’m reading the mobi version of the book on my kindle, so I don’t have a page number. The kindle reports it as location 480-89. The section entitled “Groovy as Lightweight Java” seems to be missing an example after the last bullet point. It reads “For example in the following code, the learn methods return the class so you can chain calls to learn methods:”. But there is no example. The Javabeans section begins immediately after the colon. I assume this is an issue with the mobi formatting, but haven’t verified.

37SUGGEST

Will Krespan’s erratum for page 37 is wrong. Venkat clearly states that they are out of order. It was done for illustrative purposes. Furthermore, in this example, the first parameter (location) is assumed to be a Map. Changing the order would make weight a Map, not something we want to do.

37SUGGEST

I see the point of about the reasoning of the p.37 example.
It would be nice if we could delete our erratum if we made them incorrectly. wk

187TYPO

Figure 12.2 has multiple instances of “it’s” used as a possessive.

Also, my PDF says it is the P2.0 printing, while this errata page says that P1.0 is the latest.

284TYPO

first line should read: … of the method at() …

67ERROR

Running the code in Groovy I get an error (book says it will run)

1
2
hello
Exception in thread “main” org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object ‘3hello’ with class ‘java.lang.String’ to class ‘java.lang.Integer’
\tat org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToNumber(DefaultTypeTransformation.java:127)
\tat org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:256)
\tat org.codehaus.groovy.runtime.ScriptBytecodeAdapter.castToType(ScriptBytecodeAdapter.java:598)
\tat Generics.main(GTest.groovy:18)

I am running:
Groovy Version: 1.6.3 JVM: 1.5.0_17

295SUGGEST

Add ‘as’ operator to index, as described in section 3.4 on page 39. Glen Smith was discussing this here:
grailspodcast.com/episode/68
Have posted comment on podcast site too.
About 13 minutes he started mentioing ‘as’, as being the silver bullet of handling annonymous inner classes when he was doing SWT stuff. I know I’d read about inner classes weren’t in Groovy at the time of reading either your book or GinA

228ERROR

source code
delegateTo.invokeMethod(name, *varArgs) should be
delegateTo.invokeMethod(name, varArgs),

because the original source code throw groovy.lang.MissingMethodException
, after the chagne, the code works

158TYPO

dynamic tying should be dynamic typing (line directly af the header “Using XMLParser”)

Using XMLParser
The class groovy.util.XMLParser exploits the dynamic tying and metaprogramming
capabilities of Groovy

68ERROR

Executing the code

def isPalindrome2(str)
{
if (str) {
str == str.reverse()
}
else
{
false
} println “mom is palindrome? ${isPalindrome2(‘mom’)}”
}

in a Groovy Console version 1.7.7 is printing

mom is palindrome? true

instead of

mom is palindrome? null

76ERROR

In the C code example provided at the bottom of page 76, the char* argument is referred to as “argv” in the formal parameter list; but it is referred to as the variale “value” in the code block within the method definition.

39TYPO

Substitute “print()” to println() “The $ in front of the variable it tells the method println( )..”

47ERROR

MacBookPro, snow leopard, Groovy Version: 1.7.6 JVM: 1.6.0_24
on page 47 on pdf, for Car definition, drive() method throws up compilation error since “final” variable cannot be modified outside of constructor.

49SUGGEST

in the second paragraph after code example. the sentence is not clear. it is said that the first argument is assumed to be a map, but in the call of the method, the paired value arrives in second position. confusing.

Categories: