Errata


Print Print Icon

Submit your own errata for this product.


The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.


Color Key: Serious Technical Mistake Minor Technical Mistake Language or formatting error Typo Question



Version Location Description Submitted By Corrected
Printed Page 7
2nd ruby command from the top

Hi,

When I type in the command ruby -e "puts 'Hello, Matz!'" I get the following error

-bash: !'": event not found

Cheers
Mike

Note from the Author or Editor:
Just invert "/'. Should be:

ruby -e 'puts "Hello, Matz"'

David Harrison 
Printed Page 14
2nd paragrah from the bottom

"is well-written and as complete it could possibly..."

probably intended to be-- "is well-written and as complete <<as>> it could possibly..."

Anonymous  Aug 2007
Printed Page 18
Mid-page

It should be noted the the One-Click Installer does not include the Tcl/Tk library (among others) and you
will have to download them separately. Because of this, I prefer to install Ruby on Windows using
instructions in the next section.

Anonymous 
Printed Page 23
last line of text on page

http://www.oreilly.com/catalog/learningruby

gives a 404 error

Note from the Author or Editor:
Correct.

The URL should be

http://oreilly.com/catalog/9780596529864/

Anonymous 
Printed Page 27
fourth paragraph

Here is another form. This block comment conceals several lines from the interpreter with =begin/=end:

The correction should be "Here is another form. This block comment conceals several lines from the
interpreter with =begin/=end (without any leading spaces or tabs:"

This is not a serious problem but an inadvertent space or tab will create an error msg.

Note from the Author or Editor:
Yes, I like this change.

Here is the sentence you should replace it with:

"Here is another form. This block comment conceals several lines from the interpreter with =begin/=end (without any leading spaces or tabs):"

Anonymous 
Printed Page 48
1st paragraph

There is an extra "END" on this IF statement while the previous sentence clearly tries to explain
that the keyword "END" is mandatory.

"
In addition, you don't have to use end if you write this code all on one line, like so:

x - 256
if x == 256 then puts "x equals 256" end
"

Note from the Author or Editor:
Change this sentence:

"In addition, you don't have to use end if you write this code all on one line, like so:"

To this:

"In addition, you can write this code all on one line, like so:"

Anonymous 
Printed Page 50
1st paragraph

In reference to an if / else construct, the text reads:

The 'else' keyword gives 'if' an escape hatch. In other words, if the 'if' statement does not evaluate true, the code after 'else'
will be executed, and if 'if' evaluates 'false', the code after 'else' is ignored.

Should probably be something like:
The 'else' keyword gives 'if' an escape hatch. In other words, if the 'if' statement does not evaluate
true, the code after 'else' will be executed, and if 'if' evaluates 'true', (the code after 'if' is
executed and) the code after
'else' is ignored.

Note from the Author or Editor:
Yes. Use the sentence given, except drop the parens.

Anonymous 
Printed Page 53
At the end of page, example of cash and sum

This is a logic error of how to use the variable sum. The author did not explain how to use the variable sum. I do not believe the variable sum is used in the calculation.

Note from the Author or Editor:
[Code should read:]

cash = 100_0000.00
cash += 1.00 while cash < 1_000_000.00 # underscores ignored

Anonymous 
Printed Page 65
5th para, 1st bullet

quote:

hay == nicolay # => false

...

...You could also apply the eql? method and get the same results, though eql? and == are slightly
different:

[bullet] == returns true if two objects are Strings, false otherwise

end quote.

The first bullet is wrong as your own example "hay == nicolay" shows.

See corelib.ruby, which defines == like this:

"Equality?If obj is not a String, returns false. Otherwise, returns true if str <=> obj returns zero."

Also your examples don't show any difference between "==" and ".eql?", since "hay.eql?" also returns
false.

Note from the Author or Editor:
First bullet should say:

• == returns false if right operand is not a string. Otherwise, returns true if str <=> obj returns zero.

"str <=> obj" should be formatted as code.

Anonymous 
Printed Page 68
last code sample of section 4.5.4 - The delete method

This applies to the Safari online version of the book as of May 13, 2008.

The example code doesn't generate the given output:

"That's all folks".delete "abcdefghijklmnopqrstuvwxyz", "^ha" # => "haa"

The .delete method will only delete the lowercase letters, excepting "h" and "a". It will not delete the uppercase letters ("T") or the punctuation (space and single quote), so the result is "Tha' a ", not "haa".

Note from the Author or Editor:
Change line of code to:

"That's all folks".delete "abcdefghijklmnopqrstuvwxyz", "^ha"=> "Tha' a "

Anonymous 
Printed Page 82
2nd block of command line examples

The example "12.quo 5" does not return 2.4, it returns Rational(12, 5)
To obtain that the example should be "12.0.quo 5.0"

Anonymous 
Printed Page 96
After 1st paragraph

irb(main):008:0> digits = Array(0..9)
=> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

not [1, 2, 3, 4, 5, 6, 7, 8, 9]

Anonymous 
Printed Page 102
5th code block

I believe in the fifth code block on the page (the one right above the heading

Anonymous 
Printed Page 102
5th code block

I believe in the fifth code block on the page (the one right above the heading "As a String", the elements "May", "June", and "July" should be in bold, not "June", "July", and "August".

Anonymous 
Printed Page 119
middle of page

"run the program with these three files on the command line:"

# argf.rb sonnet_29.txt sonnet_119.txt sonnet_129.txt

should be

ruby argf.rb sonnet_29.txt sonnet_119.txt sonnet_129.txt

Anonymous 
Printed Page 123
2nd paragraph

There are two mistakes in the 2nd paragraph. Original text is

Note from the Author or Editor:
Please make the following correction to the 2nd and 3rd sentences in the 2nd paragraph on page 123.

"The first argument is 1, which is the numeric file descriptor for standard output. Standard output can also be represented by the predefined Ruby variable $stdout [...]

Anonymous 
Printed Page 215
Chapter 4 review question 9

to_a was the intended answer but split(//) will work too.
Here is the difference:

irb(main):001:0> "hello there".split(//)
=> ["h", "e", "l", "l", "o", " ", "t", "h", "e", "r", "e"]

irb(main):002:0> "hello there".to_a
=> ["hello there"]

Anonymous