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 P10.0, released almost 8 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: Typo Tech. Error Suggestion Not a problem Next 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
N/A
#45139: I tried to find the errata for the first edition of this book but I was unsuccessful. The free edition hosted at ruby-doc.org reads in section...more...
P1.0
22-Sep-10
xx

#26910: "and in particular covers" should be "and, in particular, covers"--Rich Morin

P10.0
31-Jan-07
0
#29761: Dears Dave and Andy Follows some considerations about your extensible and complex book "Programming Ruby: The Pragmatic Programmer's Guide"...more...
P10.0
08-Oct-07
2

#26909: "Linux distributions, and Mac" should be "Linux distributions and Mac"--Rich Morin

P10.0
31-Jan-07
7

#27122: TO load a file in irb, you reference "code/rdoc/fib_example.rb" . This file and the directory structure does not exist in the example code..--Scott Derrick

P10.0
03-Mar-07
8

#26911: "In particular you might" should be "In particular, you might"--Rich Morin

P10.0
31-Jan-07
10

#26914: "In Ruby, you--Rich Morin

P10.0
31-Jan-07
10

#26915: "for example, the name of the song" should be "for example, the name of a song"--Rich Morin

P10.0
31-Jan-07
10

#26916: "These instance methods in turn have" should be "These instance methods, in turn, have"--Rich Morin

P10.0
31-Jan-07
12

#26917: "The following lines are both equivalent." should be "The following lines are equivalent."--Rich Morin

P10.0
31-Jan-07
12

#26918: "In this case it--Rich Morin

P10.0
31-Jan-07
14
#26913: In the second paragraph, the wording isn't really strong enough. Ruby _enforces_ these conventions. "should all start" should be "must all st...more...
P10.0
31-Jan-07
17

#43682: "The the keys and values in a hash can be..." it seems that second word "the" is a typo.--Artem Bezsmertnyi

P10.0
08-Jun-10
22

#26912: "you--Rich Morin

P10.0
31-Jan-07
26
#29389: Please change: song.inspect to puts song.inspect It is probably obvious to an experienced person, but not the person that is reading y...more...
P10.0
06-Aug-07
28

#26919: "in the real world objects often" should be "in the real world, objects often"--Rich Morin

P10.0
31-Jan-07
28

#26920: "We--Rich Morin

P10.0
31-Jan-07
29

#26921: "In Ruby you do that" should be "In Ruby, you do that"--Rich Morin

P10.0
31-Jan-07
31
#29609: This errata is in the section titled "Objects and Attributes". On the top of p. 31, the book says: "In this example, we named the accesso...more...
P10.0
02-Sep-07
31
#29613: Here is an example that led me to an erroneous conclusion about whether attr_reader creates the instance variables: class Song attr_r...more...
P10.0
03-Sep-07
41

#26922: "the end position, and the three-period" should be "the end position; the three-period"--Rich Morin

P10.0
31-Jan-07
46

#29133: Third line before last: "suggests a dequeue", I believe "deque" is intended.--Wing

P10.0
25-May-07
48
#29299: In the code for the 'find' method of class Array, the word 'size' should be '@size', I believe, since size is presumably an instance variable ...more...
P10.0
03-Jul-07
49

#44283: `while line = gets' does not return false, but instead nil. The assertion stated could cause confusion for new readers.

P10.0
26-Jul-10
60

#45624: first para:
'is generated using and ....'
=> 'is generated using ...' (I think!)--Sam Dutton

P10.0
17-Nov-10
66
#29612: In the example at the the top of p. 66, the variable song_file is undefined. It looks like the first line of the example should be something ...more...
P10.0
03-Sep-07
66
#28352: "Similarly, the patterns \b and \B match word boundaries and nonword boundaries, respectively" would be clearer as "Similarly, the patterns \b...more...
P10.0
05-Apr-07
67
#29614: In the example on the bottom of page 67, there is this line: include Comparable The include statement was not covered earlier in the boo...more...
P10.0
03-Sep-07
69

#26194: in ruby 1.8.5 =~ does not automatically convert a string on the right side to a regular expression.

P9.0
09-Oct-06
69
#28608: In the code for function show_regexp, the statements "#{$`}<<#{$&}>>#${$'}" and "no match" should be preceded by "puts", otherwise no output...more...
P6.0
16-Apr-07
70
#28216: The last sentence in the second paragraph under the section Anchors, in parentheses. in the book: ... string ends with a \n, it which case...more...
P10.0
31-Mar-07
74
#29295: The second last paragraph says "Whoever created it entered all the artists' names in lowercase.", and then goes on to explain how to make them...more...
P10.0
01-Jul-07
75
#29366: ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32] context 'The obvious thing is to write str.gsum(/\\/, '\\\\') This actually DOES wor...more...
P10.0
25-Jul-07
81
#43675: (Version of the book: 2007-09-13, P11.0) Page 81, in the fifth line from the bottom, "they must be methods..." should be "there must be metho...more...
P10.0
07-Jun-10
84

#45625: Font size is too small--Sam Dutton

P10.0
17-Nov-10
96
#29640: On p. 96, there is an example that starts with this line: words[key] ||= [ ] ... and the text says: "The first line is equivalent ...more...
P10.0
08-Sep-07
99

#47905: Ruby classes are instances of Class, which defines === to test...

=== is defined in Module not in Class.--David Bone

P10.0
06-Nov-11
99
#39302: In the custom until loop, "break if cond" will cause an error: "unexpected break (LocalJumpError)", probably because "def do_until" is a metho...more...
P10.0
02-Jun-09
104
#27026: The fact that empty rescue rescues StandardErrors should be more emphasized - a separate paragraph or a side box or at least bold font. It see...more...
P1.0
23-Feb-07
105

#28898: The do-it-yourself until loop throws a LocalJumpError from the break statement. It can be changed to a return statement.--Wing

P10.0
02-May-07
109
#28899: When the raise statement (with no parameters) is called, the exception is rethrown. Can we say a few words about the type of the error? I beli...more...
P10.0
02-May-07
114

#26904: "sum, when applied to strings it" should be "sum; when applied to strings, it"--Rich Morin

P10.0
31-Jan-07
119
#29647: On p. 118-119 is this passage: If this made you think of class methods, your next thought may well be "what happens if I define instance me...more...
P10.0
10-Sep-07
119

#28900: Need to update the code given in the website (not in the book): it still uses id instead of object_id.--Wing

P10.0
02-May-07
120
#26290: The 6th line from the bottom of the page reads, "class supports things such as map, include?, and find_all?". The name of the third method sho...more...
P9.0
17-Oct-06
120

#29394: The code near the top of the page is missing the line:
attr_reader :duration
--twscannell@hotmail.com

P10.0
09-Aug-07
122

#45626: First code example:

@observer_list ||= []
=> @observer_list = []

(I think!)--Sam Dutton

P10.0
17-Nov-10
122

#45627: paragraph 4:
'uses our Observer module'
=> 'uses our Observable module'--Sam Dutton

P10.0
17-Nov-10
127
#47906: bash-3.2# cat retry.rb for i in 1..100 print "Now at #{i}. Restart? " retry if gets =~ /^y/i end bash-3.2# irb retry.rb ruby...more...
P10.0
06-Nov-11
130
#29679: At the top of page the following code appears: count = 0 threads = [] 10.times do |i| threads[i] = Thread.new do sleep(ran...more...
P10.0
19-Sep-07
131
#29677: p. 129: Reading and Writing Files -- The are no descriptions or examples showing how to write to a file in this section. So I find the title ...more...
P10.0
19-Sep-07
143
#29348: Table 11.1 purports to demonstrate a race condition this will occur when either thread runs before the previously active thread has a chance t...more...
P10.0
22-Jul-07
145
#48801: In the "Collecting Hash Arguments" section, the book said that: > > You can place key => value pairs in an argument list, as long as they...more...
P10.0
25-Feb-12
146
#36769: Chapter 11, “Threads and Processes”, contains a section “Condition Variables”. The book gives a code example that uses a condition variable. H...more...
P10.0
01-Jan-09
146

#29349: It's not clear what the condition variable is in the code example.--bob

P10.0
22-Jul-07
149
#29680: On the bottom of p. 149 is this text and example: "For instance, we may want to kick off a long-running external sort. exec('sort testfile...more...
P10.0
20-Sep-07
153
#29736: Unit Testing, chap 12: This omitted fact caused me hours of frustration and testing until I discovered how things work. Suppose you have a s...more...
P10.0
02-Oct-07
156
#29729: p. 156, example at top of page: The output shows the test failing, but there is no description of what was entered to get the test to fail. ...more...
P10.0
01-Oct-07
160
#29737: p. 160, "Where to put Tests", middle of the page: The text says, "A better solution is to run the tests from the directory containing the lib...more...
P10.0
02-Oct-07
163
#29962: The first time I tried to use the debugger was in 186 and I am seeing something different than in v2 of the book on page 163. Or perhaps I am ...more...
P10.0
08-Dec-07
167
#36807: The book gives the following guideline: "Within a class definition, Ruby will parse setter= as an assignment to a local variable, not as a...more...
P10.0
02-Jan-09
168
#36806: In the example illustrating "Watch out for precedence issues...", the complexity of the code (which contains several branches that are not exe...more...
P10.0
02-Jan-09
173
#26439: Table 13.1 - second section (the one about disp): disp[lay] expr - Display value of nnn every time debugger gets control. should probabl...more...
P9.0
31-Oct-06
191
#26524: The output of the sample invocation `ri "String.each"' is missing the braces in the syntax synopsis. This can look confusing to first-timers (...more...
B8.0
09-Nov-06
192
#30478: Third line of first paragraph in section "Interactive Configuration": ... to change your prompt back to DEFAULT, you ... should be ... to c...more...
P6.0
16-Jan-08
193

#26905: "Both the following are" should be "Both of the following are". It might also be nice to close the sentence with a colon.--Rich Morin

P10.0
31-Jan-07
196
#26923: "return +nil+, otherwise return" should be "return +nil+; otherwise, return" (twice) Similarly, "use it, otherwise accumulate" should be "use...more...
P10.0
31-Jan-07
202

#30479: In the first line of the rdoc comment after the first paragraph, replace "though" with "through".--Felix Siegrist

P6.0
16-Jan-08
216
#29754: p. 216, Installing Ruby Gems: the two commands at the top of the page read: % cd rubygems-0.7.0 % ruby install.rb However, according to...more...
P10.0
07-Oct-07
217
#29759: p. 217, The command at the top of the page is: % gem install -r rake But, when entered that command, first I got this: $ gem install ...more...
P10.0
07-Oct-07
222
#29776: p. 222: The text says: "As of RubyGems 0.8.0, requiring rubygems.rb will install an overloaded version fo Ruby's require method. Having lo...more...
P10.0
21-Oct-07
224
#28911: Since I was checking the gems directory, I found that all the doc/ directories in gems/ are all named with the singular form, not the plural f...more...
P10.0
04-May-07
235
#36866: Two examples of a CGI script are given, where the only difference is that the second inserts a header. But this is obscured by the fact that t...more...
P10.0
04-Jan-09
237

#26906: "reformated" should be "reformatted"--Rich Morin

P10.0
31-Jan-07
251
#26874: The Google SOAP API seems no longer available for new users. Google says: <CITE> As of December 5, 2006, we are no longer issuing new API ke...more...
P6.0
23-Jan-07
257

#30480: Last paragraph: "Accessing mycheck.value will return ..." should be "Accessing checked.value will return ...". --Felix Siegrist

P6.0
16-Jan-08
292
#29635: Running the test ruby script for the my_test extension fails on OSX with: 1) Error: test_test(TestTest): NameError: uninitialized constan...more...
P10.0
07-Sep-07
298
#30477: --with-name-lib=directory Reads: "Add directory/lib to the link command" Should read: "Add directory to the link command" Similar err...more...
P6.0
16-Jan-08
309

#26761: The documented signature of rb_apply is incorrect - in fact it has no argc argument.--Jeremy Henty

P1.0
17-Dec-06
324

#29975: Table 22.4 does not list the assignment operator ^=--Morton Goldberg

P10.0
10-Dec-07
327
#48265: The description of how the three-dot range works does not match what the code actually does. Further clarification is at least required. Expr2...more...
P10.0
13-Dec-11
327

#29639: /a.*b.*a/ of course doesn't take exponential time but quadratic time.
--David Ongaro

P10.0
08-Sep-07
328

#30481: 3rd paragraph of section "Names", 1st and 2nd line: replace "a though z" and "A though Z" with "a through z" and "A through Z".--Felix Siegrist

P6.0
16-Jan-08
336

#26907: "When used as an rvalue, element reference" should be "When used as an rvalue, an element reference"--Rich Morin

P10.0
31-Jan-07
336
#29760: I'm currently using your "Programming Ruby" as a reference while learning Ruby and especially Rails. I'm highly enjoying the book. I did en...more...
P10.0
08-Oct-07
340
#25968: I believe there is a rule missing in the "Parallel Assignment" section. The last sentence on p. 91 states, "If an assignment has just one lval...more...
P7.0
21-Sep-06
342
#25969: I think some clarification of "Ranges in Boolean Expressions" is in order :) The last sentence in the first paragraph doesn't agree with the l...more...
P7.0
21-Sep-06
344

#26908: "LocalJumpError or ThreadError depending on" should be "LocalJumpError or ThreadError, depending on"--Rich Morin

P10.0
31-Jan-07
352
#29738: p. 352, Aliases: At the top of the page, the first two lines say: "When a method is aliased, the new name refers to a copy of the original...more...
P10.0
02-Oct-07
357
#36872: The code sample on page 357 could be improved in two ways: (1) The sample could demonstrate more aspects of the description at the top of the ...more...
P10.0
04-Jan-09
358

#29256: last line: "is no longer valid"--Wing

P10.0
22-Jun-07
360

#29258: Fourth line under the header "Raising Exceptions":
"raise thing [, string [stack trace]]" should be
"raise thing [, string [, stack trace]]"--Wing

P10.0
22-Jun-07
361
#47709: Page 361 Your syntax diagram for parameters is missing a comma prefixing both *array and &block parameters. Invoking a Method [ receiver....more...
P10.0
06-Oct-11
373

#30482: Section "to_ary -> Array", first line: "... convert an object ..." --Felix Siegrist

P6.0
16-Jan-08
373
#30483: Section "to_hash -> Hash", first line: "(The only known use is the second parameter to Hash#replace.)" should be "(The only known use is the p...more...
P6.0
16-Jan-08
375
#36875: The final lines of the code sample may be poorly chosen as a means to illustrate the points made in the following paragraph. The end of the...more...
P10.0
04-Jan-09
376
#26809: In the ex0629.rb and ex0629.rb program listings this line should read: if Fixnum === other && (other + @value) <= MAX_ROMAN Otherwise, a...more...
P10.0
05-Jan-07
381

#29259: In Figure 24.2, shouldn't be there an arrow linking klass of Class Object to the box of Class Object'?--Wing

P10.0
22-Jun-07
392

#26931: In the table under "Runtime Callbacks", "Module#extend_object" should be "Module#extended".--Rich Morin

P10.0
03-Feb-07
393
#29911: Regarding: "At the top-level, we're executing code in the context of some predefined object. When we define methods, we're actually c...more...
P10.0
20-Nov-07
395

#29392: The page link in "See Kernel.require on page 507 for an example." actually leads to page 495 -- the first page for Kernel.--Steven Lumos

P10.0
08-Aug-07
398

#26525: Under the $SAFE table, second sentence should read: "...or if it _is_ run under mod_ruby...", the "is" is missing.--Joachim Kuebart

B8.0
09-Nov-06
454
#36947: In the description of the "all?" method, there should be a comma after "that is" in the parenthetical expression "(that is all? will return tr...more...
P10.0
08-Jan-09
456
#29386: the description of Enumerable#inject. the text: "The first form let's you supply an initial value for memo. The second form uses the first ele...more...
P10.0
05-Aug-07
463

#34613: Under Exception#success? :

"Returns true is the exit status if nil or zero."
should read
"Returns true if the exit status is nil or zero."--Celso Frazao

P10.0
23-Sep-08
468

#30484: fnmatch, second line: "Because fnmatch in implemented..." should be "Because fnmatch is implemented...".--Felix Siegrist

P6.0
16-Jan-08
485

#30485: divmod: remove one "on".--Felix Siegrist

P6.0
16-Jan-08
487

#30486: Class constants, in the comment of MAX_EXP and MIN_EXP: replace "FLT_RADIX" with "RADIX".--Felix Siegrist

P6.0
16-Jan-08
495
#29692: In the library reference, in the Kernel module section, it says that Kernel module instance methods are listed in the Object class page, and i...more...
P10.0
23-Sep-07
499

#30487: to_hash: "See page 373." (not 372)--Felix Siegrist

P6.0
16-Jan-08
499
#26538: Both to_a and to_s show the following statement: h = { "c" => 300, "a" => 100, "d" => 400, "c" => 300 } I believe one of the "c" => 300 ...more...
P7.0
11-Nov-06
516
#29913: "The Kernel module is included by class Object, so its methods are available in every Ruby object." Here, "methods" should read "instance m...more...
P10.0
20-Nov-07
521 542
#26313: The Math.sqrt function does not raise an "ArgError" (or an ArgumentError, if that's what you meant) if 'numeric' is less than 0. On both Linu...more...
P10.0
19-Oct-06
546

#30488: Instance methods, "<, <=, >, >=", 3rd line: "... all operators return false." should be "... all operators return nil."--Felix Siegrist

P6.0
16-Jan-08
547
#29207: Under 'clone', I think it would be helpful to mention that cloned objects retain singleton methods while duped objects do not. For example, ...more...
P10.0
10-Jun-07
551

#30490: Module#module_eval: the first sample call is "mod.class_eval(...)" instead of "mod.module_eval(...)".--Felix Siegrist

P6.0
16-Jan-08
608
#26803: Perhaps it's just a one-time printing error, but at the top of the page, the small "1.8" sidenote is printed right over the word "Match", inst...more...
P10.0
03-Jan-07
609
#29441: You state in the documentation for the []= method 'the Regexp and String forms will silently ignore the assignment [if the value is out of ran...more...
P10.0
17-Aug-07
613
#29820: gsub() documentation on p.613: Above the description is the syntax: str.gsub(pattern, replacement) --string str.gsub( pattern ){|match| b...more...
P10.0
02-Nov-07
619

#29325: The documentation for str.squeeze shows it returns

-> squeezed_tring

I assume this should be

-> squeezed_string--Daniel Machera

P10.0
16-Jul-07
622

#30491: String#to_sym: the sample call is “<i>str</i>.to_s” instead of “<i>str</i>.to_sym”.--Felix Siegrist

P6.0
16-Jan-08
640

#30492: ThreadGroup, first paragraph, second line: "... will remove it from the its current group." should be "... will remove it from its current group."--Felix Siegrist

P6.0
16-Jan-08
671

#28957: $ARGV should be ARGV.--Wing

P10.0
08-May-07
673
#29287: The second paragraph says: "ERB breaks its input text into checks of regular text and program fragments." Perhaps "chunks" makes more sense t...more...
P10.0
30-Jun-07
675
#30502: Near the bottom of the page: users.join(", ") should be users=users.join(", ") groups.join(", ") should be groups=groups.join(", ") My bo...more...
P10.0
16-Jan-08
689

#30493: Library jcode, second paragraph, second line: "\343\210\202" should be "\342\210\202".--Felix Siegrist

P6.0
16-Jan-08
695

#30494: Library Monitor, second paragraph, second line: "and as a extension" -> "and as an extension".--Felix Siegrist

P6.0
16-Jan-08
712

#30495: --no-switch: "Defines a option..." -> "Defines an option...".--Felix Siegrist

P6.0
16-Jan-08
713
#30496: Library ParseDate, second line: if the time zone is included in the returned array, it's not just "an array of Fixnum values", but "an array o...more...
P6.0
16-Jan-08
718

#29789: In the 3rd sentence, "wrapper than profiles" should be "wrapper that profiles".--Brian Adkins

P7.0
24-Oct-07
725

#30497: Library REXML, in the demo.xml: "Bignums store arbitraty-sized integers." should be "Bignums store arbitrary-sized integers."--Felix Siegrist

P6.0
16-Jan-08
726
#30498: 18th line of the sample code: "# and write it out with a XML declaration at the front" should be "# and write it out with an XML declaration a...more...
P6.0
16-Jan-08
732
#26867: The first example of a weakref doesn't cause an exception. The text suggests that this is being demonstrated, but even the "produces" output s...more...
P10.0
20-Jan-07
735

#29947: In the library reference for WIN32OLE, the first example (Open Internet Explorer...) omits the necessary "require 'win32ole'" line.--Rick Ford

P10.0
05-Dec-07
759

#29402: The Zlib module does not support zip-format compressed files. To read those one has to use the rubyzip gem.--Nascif Abousalh-Neto

P1.0
13-Aug-07
762
#26674: The bookmarks section of the PDF no longer contains a link to the Index. What happened to it? Can you put it back? The last thing I see is ...more...
P10.0
29-Nov-06
768

#30499: Socket#pack_sockaddr_un: there's a typo in the sample call (Socket.pack_sockaddr_in instead of Socket.pack_sockaddr_un).--Felix Siegrist

P6.0
16-Jan-08
769

#30500: Socket#unpack_sockaddr_in: wrong sample call (Socket.pack_sockaddr_in instead of Socket.unpack_sockaddr_in).
--Felix Siegrist

P6.0
16-Jan-08
769

#30501: Socket#unpack_sockaddr_un: wrong sample call (Socket.pack_sockaddr_in instead of Socket.unpack_sockaddr_un).
--Felix Siegrist

P10.0
16-Jan-08
769
#29557: The code listing for unpack_sockaddr_un on page 769 in the Second Edition is incorrect. It is a copy of the unpack_sockadd_in code listing. Th...more...
P2.0
21-Aug-07
790
#26684: It would be nice if there was an index entry for ? that referenced pp. 319-320 where using ? to obtain the integer value of an ASCII character...more...
P7.0
29-Nov-06
863
#32686: This may have been mentioned before, but the TOC no longer contains a link to the index in the PDF version. It would be great if it could hav...more...
P10.0
08-Jul-08

Stuff To Be Considered in the Next Edition

PDF Paper Description Found in Fixed in
v-xvi,790-831

#24460: Please add bookmarks for the Tables of Contents, Tables, and Figures, the Index, and the reference tables at the back.--Steven Lumos

B8.0
12-Apr-06
105
#25365: Newer versions of ruby (1.8.4) seem to have a problem with the break in the 'retry' example (the example still works though): def do_unti...more...
B8.0
29-Jun-06
154
#25815: Suggestion for next edition Please consider changing Fig. 12.2 into something that can be searched in Apple's Preview. As it is, I get no h...more...
P9.0
30-Aug-06
174
#23916: Not sure where this piece of info would fit best, so I put in the page number for the IRB chapter. Windows users with locales (or specifica...more...
P7.0
02-Jan-06
458
#25773: It would be helpful if some of the places that describe a return value which is a numeric 'gid' or 'uid' value would also mention that the "Et...more...
P9.0
22-Aug-06
529
#25022: Description of the sleep method is incorrect for Ruby 1.8.4. Calling sleep with an argument of 'zero' as documented causes sleep to sleep for ...more...
P2.0
24-May-06