Ruby Best Practices

Errata for Ruby Best Practices

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.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
Printed Page 19
in the initialize definition

the original text says:

def initialize(in=STDIN, out=STDOUT)

"in" is a keyword; should be replaced by some other name such as "input"

Jia Wu  Aug 23, 2009 
Printed Page 20
in must "return false when parsing #{y}" do

instead of

Note from the Author or Editor:
Required change is exactly as noted.

Jia Wu  Aug 23, 2009 
Printed Page 21
in must "return false when parsing #{y}" do

instead of
must "return false when parsing #{y}" do
it should be
must "return true when parsing #{y}" do

in addition, in the line
assert !@questioner.ask(@question)
it would be nice to have more explanation afterward so that it matches the example of 'yes'. It would look like:
assert !@questioner.ask(@question), "Expected '#{n}' to be false"

Jia Wu  Aug 23, 2009 
PDF Page 26
last line

@first_name ||= '' does not mean

@first_name = @first_name || ''

it means

@first_name || @firstname = ''

according to Joerg W Mittag on Stack Overflow

The existing information may be good enough for a first look at the expression, but a footnote would be helpful.

Andrew Grimm  Apr 24, 2011 
Printed Page 89
bottom of page: class Object

insert just before the end

def find_hidden_method(name)

this allows find_hidden_method in BlankSlate to refer Object.find_hidden_method without NoMethodError when an unknown method name is sent to reveal

Wolfgang Kittenberger  Aug 10, 2009 
PDF Page 139
139 errata

The correction to the example on page 139 posted as corrected errata is also incorrect, because it does not initialize @series[0] and @series[1] and because it refers to fin(n-2)

This is correct:

def fib(n)
@series ||= []
@series[n] ||= fib(n-1) + fib(n-2)

Ray Baxter  Nov 10, 2009 
Printed Page 142
1st paragraph

The only reason that the manual cache is faster in the benchmark testing is because there is only one cache miss per run. This is due to the fact that only one rgb and one hex string is used for the 500,000 iterations in each test. Two 256-long look-up tables can be precomputed for both conversions with major speedup achieved. But the code no longer looks very 'Rubyesque', and it misses the point of the chapter.

Ethan Stryker  Feb 07, 2011