Want to receive a weekly email containing
the scoop on our new titles along with the
occasional special offer? Just click the button.
(You can always unsubscribe later by editing your
account information).

Give us an email and a password (you can use the password later to log in and
change your preferences). We'll send you a newsletter roughly once a week.

Errata for Best of Ruby Quiz

We try to keep our books accurate, but sometimes mistakes creep
in. This page lists the errors submitted by our astute readers.
If you've found a new error, please
submit it.

The latest version of the book is P1.1,
released almost 9 years ago.
If you've bought a PDF of the book and would like to upgrade
it to this version (for free), visit your
home page.

Key:TypoTech. ErrorSuggestionNot a problemNext edition

By default this page displays the errata for the latest version of
the book. If you have a previous version, select it here:

(To find out what version you have, look at the copyright page, a
few pages in from the front of the book. If it says (say)
'Second Printing', then here it'll be P2.0. If there are interim PDF
releases in that printing, they'll be 2.1, 2.2, and so on.)

PDF

Paper

Description

Found in

Fixed in

2rand

2rand

#47532: +z$8frZdyL%68pSU/:>w<:E3.lG-!XIB--vvqKGQyCZkkJ

P1.1
10-Sep-11

62

#24428: if the solution "erb_madlibs.rb" should also work with placeholders which run over multiple lines like in example "Gift_Giving.madlib", the reg expression "/\(\(\s*(.+?)\s*\)\)/" should have at least a multiline option e.g. "/\(\(\s*(.+?)\s*\)\)/m"--Dietmar

#24428: if the solution "erb_madlibs.rb" should also work with placeholders which run over multiple lines like in example "Gift_Giving.madlib", the re...more...

P1.1
09-Apr-06

67

#24429: "... . Otherwise, the sub( ) call will fail, and $1 will be unaltered. ... "
As I can see $1 will get Nil and the assignment of the user input to h[$1] won't be relevant for further hash calls in the gsub block.--Dietmar

#24429: "... . Otherwise, the sub( ) call will fail, and $1 will be unaltered. ... "
As I can see $1 will get Nil and the assignment of the user inpu...more...

P1.1
09-Apr-06

72

#36368: A very minor issue concerning the usage conditions for erb_madlib.rb.

I suggest checking that the file extension name for the madlib input file is .madlib by adding a File.extname(ARGV[0]) == ".madlib" to the usage unless conditions.

Currently, if the file is, say, Lunch Hungers.madlip, and that file exists, when the story prints out, the title at the top of the screen will be Lunch Hungers.madlip instead of just Lunch Hungers (the File.basename(ARGV.first, '.madlib') condition fails). --Paul Fioravanti

#36368: A very minor issue concerning the usage conditions for erb_madlib.rb.
I suggest checking that the file extension name for the madlib input ...more...

P1.1
10-Dec-08

116-7

#24300: In the "unusual construct", "method({key => value})", the braces are unnecessary; the named-argument style "method(key => value)" should be used.--Dave Burt

P1.1
16-Mar-06

138-9

#24301: There are three lines in my code where I "throw" exceptions instead of using "raise" or "fail". It will cause an error, just not the intended one. That's a mistake you can easily make coming from Java.--Dave Burt

#24301: There are three lines in my code where I "throw" exceptions instead of using "raise" or "fail". It will cause an error, just not the intended ...more...

P1.1
16-Mar-06

169

#24434: Method Cipher.normalize is incorrect.

The easiest way to verify this is to add the following test to tc_cipher's test_normalize.

The problem is with line two of Cipher.normalize:
text += ("X" * (text.length % 5))

This code adds only (text.length%5) number of "X"s, which is not enough if text.length is 1 or 2. You could fix this by correctly computing the number of X's necessary to pad out to a multiple of 5, or take my more brute force approach of replacing this line with the following:

text += "XXXX"

Since 4 is the maximum number of X's that could be needed, and the extras will harmlessly be thrown out by the following line: