Errata for Programming Ruby 1.9
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 P2.0, released 10 months 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.
| Paper | Description | Found in | Fixed in | |
|---|---|---|---|---|
| TOC |
#38958: The page numbers in the Table of contents, index, etc. are 1 too small--David C. Toll |
P2.0
22-Apr-09 |
||
| All |
#38976: The page numbers in cross references are 1 below what they should be.--David C. Toll |
P2.0
23-Apr-09 |
||
| all |
#40656: It would be nice to have the chapter number next to the chapter name on top of each page. Also, the PDF table of contents should include cha...more...
|
P2.0
03-Sep-09 |
||
| 56 |
#39256: Some text was cut away, last text was: " have an exact internal representation. When we " --Sebastian Rydberg Dave Thomas says: the footnote continues on the next page… |
P2.0
27-May-09 |
||
| 57 |
#39217: Assignment method is:
def price_in_cents=(cents)
@price = cents / 100
end
Shouldn't the middle line be:
@price = Float(cents) / 1...more...
Dave Thomas says: It is divided by 100.0, so the operation is performed in floating point automatically.
|
P2.0
18-May-09 |
||
| 57 |
#41673: In the method price_in_cents, shouldn't the "price" variable name be "@price"? I'm not sure why it does work if the explanation in the final p...more...
Dave Thomas says: It uses the accessor method price.
|
P2.0
01-Dec-09 |
||
| 81 |
#39836: Technically, one might say that a :fox is "vulpine". One would use "lupine" for a :wolf, maybe. :-)--Ron Lusk |
P2.0
06-Jul-09 |
||
| 88 |
#40872: The line of sample code in tutcontainers_63.rb that reads:
proc3 = ->(arg1, arg2) { puts "In proc3 with #{arg1} and #{arg2}" }
...only s...more...
Dave Thomas says: Indeed. I find the whole syntax for this to be ugly.
|
P2.0
26-Sep-09 |
||
| 98 |
#40934: Last paragraph, line 4 says "A module can't have instances,.."
Line 6 says "When this happens, all the module’s instance
methods are suddenl...more...
Dave Thomas says: Not really, because a module can also have module methods.
It's a confusing part of the language: a module does have instance methods, but you can't create instances of the module, and therefore you can't use the instance methods directly.
|
P2.0
05-Oct-09 |
||
| 99 |
#40978: Code in book is incorrect. Code in download is correct.--Ron Green |
P2.0
11-Oct-09 |
||
| 118 |
#40655: A sentence near the bottom says:
"nil is equivalent to false in Ruby"
but the Ruby interpreter disagrees:
irb(main):110:0> nil == fal...more...
Dave Thomas says: Nil is equivalent to false in a boolean context. I'll add the extra words in the next printing.
|
P2.0
03-Sep-09 |
||
| 119 |
#40849: In the section "Changing Strings with Patterns" shouldn't the first sentence read: "The sub method takes…?"--Bruce Hobbs |
P2.0
22-Sep-09 |
||
| 131 |
#39096: "subsubtring" where "substring" should be used: "You’ll sometimes want to match a pattern only if the matched subsubtring is preceded by or fo...more...
|
P2.0
04-May-09 |
||
| 133 |
#39097: Either the word "refer" or the word "count" should be removed from this sentence: "Negative backreference numbers refer count backward from t...more...
|
P2.0
04-May-09 |
||
| 139 |
#40923: In the last sentence of the second-to-the-last paragraph shouldn't "argument" at the end of the sentence be pluralized?--Bruce Hobbs |
P2.0
03-Oct-09 |
||
| 141 |
#40936: When object writer is being initialized, the string my_order should be surrounded by double quotes. As written, ruby will look for a variable ...more...
Dave Thomas says: I'm just assuming you have an order lying around—it's not supposed to be anything special
|
P2.0
06-Oct-09 |
||
| 143 |
#40856: For the section Splat! Expanding Collections in Method Calls, the 1.9 marker is in front of the paragraph "When you call a method . . ."
Th...more...
|
P2.0
24-Sep-09 |
||
| 186 |
#40143: In 'unittesting_3.rb':
class TestRoman < MiniTest::Unit::TestCase
of course it is Test::Unit::TestCase and it is correct in the subsequent...more...
|
P1.0
22-Jul-09 |
||
| 198 |
#39522: The second paragraph has 'expectations' misspelled twice: "expections" in the second line and "expecations" in the fourth line.--Octav Popescu |
P1.0
17-Jun-09 |
||
| 235 |
#39943: The -W description has "level or two". should be "level of two"
|
P2.0
11-Jul-09 |
||
| 243 |
#40432: I believe that packaging_14.rb should be placed in "lib/anagram/runner.rb" not in "lib/runner.rb"--Patrick |
P2.0
11-Aug-09 |
||
| 255 |
#40154: I read: "String literals are always encoded using the encoding of the source file that contains them, regardless of the content of the string"...more...
|
P1.0
23-Jul-09 |
||
| 270 |
#39001: Apparently, there was a mixup between ∂ (U+2202) and δ (U+3B4). All examples are given with δ but the codepoints are those of ∂. Thus there ar...more...
Dave Thomas says: It's just the way TeX prints the character.
|
P2.0
25-Apr-09 |
||
| 271 |
#39554: The paragraph under 'Interactive Configuration' says: "For example to change your prompt back to DEFAULT you could use the following:" but the...more...
|
P1.0
19-Jun-09 |
||
| 306 |
#41972: Under section "Getting and Setting properties", the sentence "excel2.rb ( found in the ext/win32/samples directory)" should be "ext/win32ole/s...more...
|
P1.0
01-Jan-10 |
||
| 306 |
#41973: The source code of modified excel2.rb is not working, it throws exception:
excel2.rb:7:in `[]=': (in OLE method `visible': ) (WIN32OLERuntime...more...
|
P1.0
01-Jan-10 |
||
| 307 |
#41974: The IE navigate ruby code win32_11.rb is not working, it throws the following exception:
win32_11.rb:40:in `message_loop': method `backtrac...more...
|
P1.0
01-Jan-10 |
||
| 309 |
#41975: ext\win32ole\samples directory should be ext\win32ole\sample directory--Steve Zhang |
P1.0
01-Jan-10 |
||
| 310 |
#41976: The code of win32_15.rb is not working, it throws following exception:
win32_15.rb:15:in `[]': wrong number of arguments(2 for 1) (Argument...more...
|
P1.0
01-Jan-10 |
||
| 316 |
#40445: I am a relative newby to Ruby, but in a book that describes itself as "a tutorial" (page xxi), the example in the MS Windows section asks the ...more...
|
P2.0
13-Aug-09 |
||
| 328 | 328 |
#40567: In the 1.9 specific Section 'Rational and Complex Numbers': "There are for rational or complex literals, for example."--Janos Sebok |
P2.0
26-Aug-09 |
|
| 328 |
#41080: You write: the form with single quotes converts \'
into a single quote
It appears that \x maps to x if x is the quote character or one of...more...
|
P2.0
25-Oct-09 |
||
| 337 |
#39436: The description for first form of 'case' expressions says: "case when condition ..." while the description for "if" and other similar expressi...more...
|
P1.0
13-Jun-09 |
||
| 337 |
#39185: I can not reproduce the behavior of class variable as described on pages 337 and 338 of Programming Ruby 1.9.
Here is a file with Ruby code...more...
|
P2.0
12-May-09 |
||
| 337 |
#39186: With respect to erratum #39185, I tried the same code on an older Ruby build:
$ ruby -v
1.9.0 (2006-06-08) [x86_64-linux]
With this ver...more...
|
P2.0
12-May-09 |
||
| 339 |
#39435: The second paragraph for section "break, redo, next, and retry" says: "retry restarts the loop, reevaluating the condition." However on page 1...more...
|
P1.0
13-Jun-09 |
||
| 341 |
#39292: Description of $stdout states: "Assignment to $stdout is not permitted: use $stdout.reopen instead."
I believe this is not exact. STDOUT ca...more...
|
P2.0
31-May-09 |
||
| 341 |
#39293: $> states: "The default value is $stdout." it should be STDOUT, not $stdout. Also it would be helpful if it was noted that $> and $stdout are aliases.--Marc-Andre Lafortune |
P2.0
31-May-09 |
||
| 349 |
#39443: First paragraph says: "... A module may contain class and instance methods and may define constants and class variables. As with classes, modu...more...
|
P1.0
14-Jun-09 |
||
| 351 |
#40570: The retry keyword is still mentioned in the section 'break, redo, next, and retry' as a control flow modifier for loops, but retry is not vali...more...
|
P2.0
26-Aug-09 |
||
| 351 |
#40833: The section headed "break, redo, next, and retry" says:
"If used within a while, until, or for loop, the value given to break is returned a...more...
|
P2.0
21-Sep-09 |
||
| 353 |
#39444: First paragraph for 'Calling a Proc' says: "You can call a proc by invoking its methods call, yield, or []. The three forms are identical." No...more...
Dave Thomas says: Works fine
|
P1.0
14-Jun-09 |
||
| 353 |
#39445: Second paragraph for 'Calling a Proc' says: "You can also invoke a proc using the syntax name.(args...). This is mapped internally into a.call...more...
|
P1.0
14-Jun-09 |
||
| 355 |
#39446: Second line in first paragraph has "exceptioons".--Octav Popescu |
P1.0
14-Jun-09 |
||
| 365 |
#40751: The description of 'next' doesn't give a good idea of what it does. Indeed, remove the 'next' keyword in the 4 examples and the result is the same... --Marc-Andre Lafortune |
P2.0
15-Sep-09 |
||
| 366 |
#41078: Dave, you set up two terms "raw block" and "lambda" at the top of the previous page. But when describing the precise details of return, break...more...
|
P2.0
25-Oct-09 |
||
| 367 |
#39645: Top of page: "exceptioons" should be "exceptions".--Kenneth Ballou |
P2.0
25-Jun-09 |
||
| 379 |
#40810: names = %{ant bee cat}
results in the string "ant bee cat". What you want instead is
names = %w{ant bee cat}
which resul...more...
|
P2.0
19-Sep-09 |
||
| 396 |
#39478: Last paragraph says: "Previously, constants were looked up in the lexical scope in which there were referenced." It should be "...they were re...more...
|
P1.0
16-Jun-09 |
||
| 399 |
#39479: First paragraph ends with "Because of this, most people are moving away from this style of CFinstance_evaled block." Not clear what 'CF' stand...more...
|
P1.0
16-Jun-09 |
||
| 402 |
#39848: In classes_57.rb the name parameter to method missing is a Symbol not a String as assumed by the code.
The line
name[-1] == "="
throws "u...more...
Dave Thomas says: Works here
|
P1.0
07-Jul-09 |
||
| 406 |
#40841: In section "instance_eval and class_eval",
First paragraph says: "The methods Object#instance_eval, Object#class_eval, and Object#module_ev...more...
|
P2.0
22-Sep-09 |
||
| 406 |
#41158: On page 406 of Programming Ruby 1.9 I read:
"In contrast, instance_eval acts as if you were working inside the singleton class of self.
Th...more...
|
P2.0
03-Nov-09 |
||
| 407 | 396 |
#41001: "Previously it was impossible to pass a local or instance variable into a block..." shouldn't say "local" since those are captured by the clos...more...
|
P2.0
16-Oct-09 |
|
| 426 |
#41075: Running the code in ruby 1.9.1 with -W2 gives a warning of "method redefined". (See gist 217992) I'm not sure which of undef_method or remove_...more...
|
P2.0
25-Oct-09 |
||
| 438 |
#39605: Second paragraph, third line: "tha" should be "the" ("the safe level of the code that invoked tha [sic] proc").--Kenneth Ballou |
P2.0
22-Jun-09 |
||
| 448 |
#42005: The fact that the interface for most methods of array use "enum" instead "arr" or whatever is a bit surprising and could mislead the reader in...more...
|
P2.0
04-Jan-10 |
||
| 448 |
#38973: In the specification of the instance methods for class Array, on pages 448 on, it uses "enum" for each array reference (the same as is used la...more...
|
P2.0
23-Apr-09 |
||
| 449 |
#41119: Array#<=> can also return nil (when the argument is not comparable)--Marc-Andre Lafortune |
P2.0
27-Oct-09 |
||
| 452 |
#38984: In Array#cycle, the following should be removed:
|
P2.0
24-Apr-09 |
||
| 454 |
#39089: Array#find_index returns an enumerator if no block and no argument is given--Marc-Andre Lafortune |
P2.0
04-May-09 |
||
| 455 |
#38985: Interface of Array#frozen: "frozen?!".gsub("!","")--Marc-Andre Lafortune |
P2.0
24-Apr-09 |
||
| 457 |
#42004: Array#permutation's interface and doc should reflect the fact that the size argument is optional.--Marc-Andre Lafortune |
P2.0
04-Jan-10 |
||
| 466 |
#41120: Bignum#<=> can also return nil (when the argument is not comparable), same for all classes--Marc-Andre Lafortune |
P2.0
27-Oct-09 |
||
| 483 |
#41914: s/UTF-*/UTF-8/ (you forgot to release the shift key :-)
|
P2.0
25-Dec-09 |
||
| 487 |
#39360: The first section of the Enumerator description says:
"Some of the methods in the Enumerable module can return an Enumerator object"
But t...more...
|
P1.0
07-Jun-09 |
||
| 487 |
#41172: Shouldn't the first sentence of the description for the any? method indicate that collection elements are only passed until the given block re...more...
|
P2.0
04-Nov-09 |
||
| 488 |
#38983: Enumerable#detect should have a "1.9" symbol next to it, since it can now be called without a block--Marc-Andre Lafortune |
P2.0
24-Apr-09 |
||
| 489 |
#39088: Enumerable#find_index can also be given a single argument (as shown in Array#find_index)--Marc-Andre Lafortune |
P2.0
04-May-09 |
||
| 493 |
#39156: "that is, any? will return true..." should read "that is, one? will return true..."--Geoff Jacobsen |
P2.0
09-May-09 |
||
| 496 |
#39003: I believe the syntax Enumerator.new{ some block } is new to Ruby 1.9 and thus should have a "1.9" symbol next to it.--Marc-Andre Lafortune |
P2.0
25-Apr-09 |
||
| 498 |
#39098: Enumerator#next is 1.9 only, so there should be a "1.9" symbol next to it.--Marc-Andre Lafortune |
P2.0
04-May-09 |
||
| 503 |
#42205: in File.new, it says See also IO.open on page 505 but IO.open is on page 540--PragProg Fan |
P2.0
28-Jan-10 |
||
| 533 |
#39188: Hash.[] has two other forms. The second and third form take a single argument which is either an array of key-value pairs or an object convert...more...
|
P2.0
12-May-09 |
||
| 535 |
#38990: Missing ")" in interface after "hsh.assoc( key"--Marc-Andre Lafortune |
P2.0
24-Apr-09 |
||
| 537 |
#38860: Hash#delete_if: interface probably shouldn't have the ⟨ ⟩ around the block. Same with Hash#reject!--Marc-Andre Lafortune |
P2.0
13-Apr-09 |
||
| 540 |
#38859: Interface of Hash#rassoc missing the closing parenthesis.--Marc-Andre Lafortune |
P2.0
13-Apr-09 |
||
| 541 |
#41200: Hash#select returns a hash (correct in doc, incorrect in interface line)--Marc-Andre Lafortune |
P2.0
06-Nov-09 |
||
| 542 |
#38974: The specification of the method "to_hash" says "see page 375. I think this should be page 378.--David C. Toll |
P2.0
23-Apr-09 |
||
| 544 |
#41910: decription of odd? is: Returns true is int is odd. should be: Returns true if int is odd.--Dave Colburn |
P2.0
23-Dec-09 |
||
| 556 |
#40979: The result of the Rational method says 'complex', it should probably say 'rational'.--Octav Popescu |
P1.0
11-Oct-09 |
||
| 556 |
#40498: IO#gets: The line "If separator is nil, the entire file is passed as a single string." is redundant, this was stated in the previous line.--Marc-Andre Lafortune |
P2.0
19-Aug-09 |
||
| 559 |
#38959: For "readbyte", it says "Returns the next 8-byte byte". I suspect this should be "8-bit byte".--David C. Toll |
P2.0
22-Apr-09 |
||
| 568 |
#38967: This line looks a bit sketchy:
--Cornelius Reiber Dave Thomas says: It should say "only *if*", not "only *with*") |
P2.0
23-Apr-09 |
||
| 574 |
#39146: #39013: The bottom of the page describing Marshal is cut off.--Dave Thomas
1, Erratum noted above references page 584, should be 574
(a...more...
|
P2.0
07-May-09 |
||
| 584 |
#39013: The bottom of the page describing Marshal is cut off.--Dave Thomas |
P2.0
26-Apr-09 |
||
| 590 |
#41146: Math.log takes a second optional argument (base).--Marc-Andre Lafortune |
P2.0
31-Oct-09 |
||
| 591 |
#39049: Method#arity refers to Method#parameters. AFAIK, such a method does not exist (yet).--Marc-Andre Lafortune |
P2.0
01-May-09 |
||
| 595 |
#40838: Module#<, <=, ... "all operators return false" should be
|
P2.0
21-Sep-09 |
||
| 606 |
#40844: The method parameter can be a Proc or Method object
|
P2.0
22-Sep-09 |
||
| 607 |
#39855: In the "1.9" note for define_method, "This methods" should read "These methods". |
P2.0
07-Jul-09 |
||
| 613 |
#39548: The header for class Object shows it has not superclass. However in Ruby 1.9 it has BasicObject as superclass.--Octav Popescu |
P1.0
18-Jun-09 |
||
| 621 |
#39022: In Ruby 1.9, retuns an enumerator if no block is given.--Marc-Andre Lafortune |
P2.0
28-Apr-09 |
||
| 621 |
#40828: Documentation for Numeric#remainder is not exact. x.remainder(y) = x - (x/y).truncate
|
P2.0
21-Sep-09 |
||
| 621 |
#39050: Oups, sorry, I meant to say Numeric#step returns an enumerator if no block is given (in Ruby 1.9), so the interface should change, and a "1.9"...more...
|
P2.0
01-May-09 |
||
| 622 |
#38982: obj =~ other_obj
should be obj !~ other_obj
|
P2.0
24-Apr-09 |
||
| 623 |
#40574: In the synopsis of define_singleton_method, the second line reads "obj.define_method(symbol) { block } -> proc". I believe "define_method" sh...more...
|
P2.0
27-Aug-09 |
||
| 623 |
#40845: The method parameter can be a Proc or Method object
|
P2.0
22-Sep-09 |
||
| 625 |
#41164: Object#___id__ is not new in Ruby 1.9, so there should be not "1.9" icon next to it.--Marc-Andre Lafortune |
P2.0
03-Nov-09 |
||
| 631 |
#39016: Missing closing parenthesis after + in Object#to_enum interface--Marc-Andre Lafortune |
P2.0
26-Apr-09 |
||
| 642 |
#40871: Proces.exec: signature is missing the optional env (see Kernel.exec)--Marc-Andre Lafortune |
P2.0
26-Sep-09 |
||
| 676 |
#40456: The return value of the method String#partition is printed as "[ before, match after ]". Shouldn't it be "[ before, match, after ]"?
This t...more...
|
P1.0
16-Aug-09 |
||
| 677 |
#40457: The return value of the method String#rstrip! is on it's own line. Shouldn't they be on the same line?
It appears like this:
... str.rstr...more...
|
P2.0
16-Aug-09 |
||
| 681 |
#41604: String#gsub! can also return an enumerator, so the interface should show it (like String#gsub)--Marc-Andre Lafortune |
P2.0
23-Nov-09 |
||
| 681 |
#38911: Interface of String#gsub has second and third form on the same line--Marc-Andre Lafortune |
P2.0
17-Apr-09 |
||
| 688 |
#38965: The first line of the description of slice! starts "Deletes the specified portion from strand....."
There is a space missing between "str" ...more...
|
P2.0
22-Apr-09 |
||
| 688 |
#38975: In the specification of slice!, it says that "this is a string".slice!(3..6) returns " is ". When I try it I get "s is". --David C. Toll Dave Thomas says: The previous line removes the 'i', so all the characters have shifted down. |
P2.0
23-Apr-09 |
||
| 695 |
#39002: String#upto has a second optional argument.--Marc-Andre Lafortune |
P2.0
25-Apr-09 |
||
| 699 |
#39135: The 'members' instance method of Struct returns an array of symbols rather than strings, and this is a change in 1.9.
members joe.members →...more...
|
P2.0
07-May-09 |
||
| 707 |
#40681: Thread#[]
The current example is not informative; the "produces" section shows what happens if the new threads have not had the time to execu...more...
|
P2.0
07-Sep-09 |
||
| 708 |
#40965: Thread#group has not changed from Ruby 1.8 to 1.9, so there should be no "1.9" sign next to it.
|
P2.0
09-Oct-09 |
||
| 754 |
#38871: First line of text: "generator-lke" should be "generator-like"--Kim Shrier |
P2.0
14-Apr-09 |
||
| 789 |
#40897: "Because Ruby does not use operating system threads..." is not true for 1.9.--George Lippert |
P2.0
30-Sep-09 |
||
| 807 |
#39053: "It's" should not have an apostrophe in "the module uses it’s random_bytes method"--Andrew Grimm |
P2.0
01-May-09 |
||
| 830 |
#40462: In the table "C Data Types to Ruby Objects" LONG2NUM is lacking the end parenthesis.--Henrik Hodne |
P1.0
17-Aug-09 |
||
| 841 |
#41295: 'rb_global_variable' takes a pointer as its argument.
This section...
static VALUE obj;
// ...
obj = rb_ary_new();
rb_global_variable(o...more...
|
P2.0
10-Nov-09 |
||
| 879 |
#40433: On the top of the page (in the header), on the right side, it says 'require "mkmf"'. Shouldn't this be 'require "socket"'? This typos is on al...more...
|
P2.0
12-Aug-09 |
