Errata

Head First Ruby

Errata for Head First Ruby

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 "Date 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 Note Update

Version Location Description Submitted By Date submitted Date corrected
Printed
Page 104
First code block

"#{@name} the dog, age #{age}"

#{age} must be #{@age}

Note from the Author or Editor:
The code actually works as printed, because it calls the "age" attr_reader method inherited from the Animal class. But this is indeed a typo; I intended to access the @age instance variable just as I did with the @name instance variable.

Martin Reijinga  Jan 29, 2016 
Printed
Page 143
second to last paragraph

The "print_pay_stub" methods never used "super". They just used the inherited "print_name" method.

Note from the Author or Editor:
On page 143, change this text:

In the previous chapter, we used super within our print_pay_stub methods in SalariedEmployee and HourlyEmployee to delegate printing of the employee name to the Employee superclass. Now we’ve just done the same thing with the initialize method, allowing the superclass to handle setting of the name attribute.

To this:

In the previous chapter, we used super within ordinary instance methods like the greet_by_name method of Friend or the move method of Armadillo to delegate part of the method functionality to the superclass. Now we’ve just done the same thing with the initialize method of our employee subclasses, allowing the superclass to handle setting of the name attribute.

Stefan Pochmann  Nov 18, 2017 
PDF
Page 147
Figure at the bottom, right of the page

There is a figure that appears to be a reference figure left in by mistake. No text refers to it, and it has nothing to do with the context of the text on the page. It contains the following text:

down_arrows
short_downward_arrows
downward_arrow
horizontal_arrow
upward_arrow
up_arrows

And it has arrows pointing to it from all sides.

The figure does no damage to the text or the topic under discussion. It just looks random.

Note from the Author or Editor:
The referenced figure is a template item accidentally left in during the layout process. It should be removed.

Brad Collins  Feb 06, 2016 
PDF
Page 157
Code after 3rd paragraph

Previously, we declared this array:

prices = [2.99, 25.00, 9.99]

Then, we want to print out the array contents using the 'puts' method, but the ebook shows wrong array contents:

puts prices[0] /=> 3.99
puts prices[2] /=> 25.0
puts prices[1] /=> 8.99

The correct text should be this:

puts prices[0] /=> 2.99
puts prices[2] /=> 25.0
puts prices[1] /=> 9.99

Note from the Author or Editor:
The displayed output is indeed incorrect, but the corrected output submitted by the reader is in the wrong order. The corrected text should be:

puts prices[0] /=> 2.99
puts prices[2] /=> 9.99
puts prices[1] /=> 25.0

Eder Andrés Ávila Niño  Jan 24, 2016 
Printed
Page 165
Second paragraph

The first line of the paragraph reads:
"...the logic in total, refund, and show_variables..."

and it should read:
"..the logic in total, refund and show_discounts..."

Note from the Author or Editor:
Confirmed. Text should be changed as described by submitter.

Stephen Grell  Mar 20, 2016 
PDF
Page 194
Content of

Throughout the chapter, the text "Truncated is funny: it can't..." within the "reviews.txt" sample file should be listed as "Truncated is funny - it can't..." (with a space-dash-space instead of a colon). As it appears now, the final result ends up appearing as: "The critics agree, Truncated is:\n'Amazing'\n'Funny:'\n'Astounding'", with a colon following one of the adjectives.

Content originating from the "reviews.txt" file needs to be changed on the following pages:
194
201
202
203
212

Thanks to Caleb Engelken for submitting this!

Jay McGavren
Jay McGavren
 
Jun 02, 2016 
Printed
Page 198
right column Q and A

"Our own version" of "File.open" should really close the file after the "yield". After all, the automatic closing was the whole reason we switched to using a block, and you made quite a big point out of that in the previous two pages (and again mentioned it in the chapter's ending "bullet points"). It's also only one extra line, so it's not like that would make the example too complicated. On the contrary, I find the *lack* of closing irritating.

Note from the Author or Editor:
On page 198, this code sample under "There Are No Dumb Questions":

def File.open(name, mode)
file = File.new(name, mode)
if block_given?
yield(file)
else
return file
end
end

Should be updated to:

def File.open(name, mode)
file = File.new(name, mode)
if block_given?
yield(file)
else
return file
end
file.close
end

Stefan Pochmann  Nov 18, 2017 
ePub
Page 365
Graphic just before "The real problem here is ..."

There is a graphic labeled, "Can we even eat these?" with a curly brace. The graphic and its text of the graphic appears in the PDF version:

Turning oven off.
Serving You need to turn the oven on first!.
Serving You need to turn the oven on first!.
Serving You need to turn the oven on first!.

The graphic appears to be missing from the ePub version. The label and the curly brace are there, but the graphic containing the puts output does not appear in my reader.

Note from the Author or Editor:
I believe the reader may have meant to reference page 361 of the print/PDF version as the place the output text appears correctly, not page 365. Confirmed that the output text box containing "Serving You need to turn the oven on first!." (etc.) is missing from page 568 of the ePub version.

Brad Collins  Feb 22, 2016 
Printed
Page 394

On this and all subsequent code listings for Chapter 13, the Minitest::Test class is used. This works fine in Minitest 5.0 and later, but in Minitest 4.3.2 (which is included with Ruby 2.0), the class's name is Minitest::Unit::TestCase. References to Minitest::Test result in a NameError, as that class does not exist in Minitest 4.3.2.

The solution is to install a later version of Minitest, by running "gem install minitest" at a system command prompt.

Jay McGavren
Jay McGavren
 
Dec 09, 2015  Dec 11, 2015
PDF
Page 429
"There are no dumb questions" section

sinatra myserver.rb -p 8080 would cause Sinatra to listen on port 8080
should be:
ruby myserver.rb -p 8080 would cause Sinatra to listen on port 8080

Note from the Author or Editor:
Command text should be modified as described by submitter.

Anonymous  May 27, 2016 
Mobi
Page 6037
2nd paragraph

Kindle edition, location 6037 of 9874. At the end of the paragraph just above the section labelled "Ensuring the oven gets turned off", there is a trailing "An" that should be removed.

Note from the Author or Editor:
This issue appears to be exclusive to the .mobi version, as it does not occur in the .pdf or print versions. The last sentence prior to the "Ensuring the oven gets turned off" section should be changed from this:

"An"

To this:

"An ensure clause is a great place to put this sort of code."

...with the word "ensure" in the code font.

Anonymous  Jan 11, 2016 
Mobi
Page 6079
"Relex" sidebar heading

"Relex" sidebar heading in "The Ruby standard library" section should say "Relax". .mobi location 6079 of 10423. This typo occurs only in the .mobi version, not the PDF or print versions.

Jay McGavren
Jay McGavren
 
Jan 11, 2016