By Developers, For Developers

Historical errata for Programming Ruby 1.9

PDF PgPaper PgTypeDescriptionFixed onComments
137TYPO

“Although threads can no take advantage” => “Although
threads can now take advantage”

2007-12-13
137TYPO

“but only every operates a single thread” => “but only ever operates a single thread”

2007-12-13
79TYPO

“You can create an Enumerator object by calling the to_enumethod” should say “to_enum method”

2007-12-14
160TYPO

“manually scheduling threads without involved any …” should read “involving”

2007-12-14
162TYPO

“it uses native operating system, but only ever operates a single thread at a time” should (I think) read “uses native operating system threads”

2007-12-14
162TYPO

“You’ll never see two thread in the same application” should read “threads”

2007-12-14
162TYPO

“By calling join on each of the requestor threads” should be “requester”, according to my dictionary (Chambers), but this may just be a US versus Australian/British English difference.

2007-12-14
75TYPO

“What’s more, these rules changes significantly with Ruby 1.9” should read either “change” or “changed”.

2007-12-14
19TYPO

“…(an implementation in Java from runs of the JVM),..” should be “that” instead of “from”

2007-12-14
161TYPO

Towards the middle of the page, there’s a sentence, “For now, the code is the block is not executed.” It looks like it should read, “The code in the block”.

2008-01-09
60SUGGEST

Change “def MyLogger.create” to “def self.create” - since somewhere before this page you wrote that this is the new/preferred/modern idiom.

2008-01-09
20TYPO

In note 1 at the bottom of the page, the phrase “Development versions of the software had off minor version numbers…”. The word ‘off’ should be ‘odd’.

2008-01-09
161TYPO

In “We could fix this by writing a class which reads the file and yields each successive work.” “work” should be “word”.

2008-01-09
42OK

The 1.9 note on the new literal hash syntax says “in fact hashes are so frequently used that 1.9 introduces a new hash syntax.”

I don’t think thats the motivation. The real motivation is for use of hashes as keyword parameters to methods.

I’d suggest changing this to something like “Ruby 1.9 has introduced an additional syntax for hashes which is more compact …”

2008-01-09
109SUGGEST

At the bottom of this page (tagged with 1.9):

“Do this by prefixing the array argument (which must follow all the regular arguments)”

then on the next page examples which include splat parameters anywhere in the parameter list, and the following:

As of Ruby 1.9, splat arguments can appear anywhere in the parameter list, and you can intermix splat and regular arguments.

2008-01-09
42TYPO

First paragraph:

“Ruby also guarantees that n matter…” — should be “no” not “n”

2008-01-09
112SUGGEST

This describes a 1.9 feature, but doesn’t have the little icon on the side of the page. Should add…

2008-01-09
149SUGGEST

“Alternatively, the module could use a module-level hash, indexed by the current object ID, to store instance-specific data without using Ruby instance variables.” It should be useful to add a warning for this way : the instance-specific data will not be removed if the GC kill the object…

2008-01-09
87SUGGEST

While the code at the bottom of the page works (samples/tutstdtypes_12.rb), it’s not clear (to me at least) why. Why does there have to be a comma between the two opening ’<<’s? Why can’t you nest them so STRING2 terminates before STRING1? In general, it seems to be a more complicated example than you are trying to get across I think it either needs simplifying or more explanation.

PS Submission form doesn’t seem to work with Opera

2008-01-09
657TYPO

The method prototype contains a type “_tring” when you mean “_string.”

str.squeeze( < string > ) → squeezed_tring

Should be

str.squeeze( < string > ) → squeezed_string

2008-01-09
65ERROR

In the text towards the bottom of the page you say,

“You can also prevent anyone from changing a particular object by freezing it (we talk more about freezing objects on page 413). Attempt to alter a frozen object, and Ruby will raise a TypeError exception.”

But when you run the example code, a RuntimeError is raised. The above text is incorrect and should read:

“You can also prevent anyone from changing a particular object by freezing it (we talk more about freezing objects on page 413). Attempt to alter a frozen object, and Ruby will raise a RuntimeError exception.”

2008-01-09
781SUGGEST

Chapter 28 (extending ruby) doesn’t discuss the treading model in 1.9, and the big VM lock. I think this is a big change, and should be addressed, so people can write better extensions.

Excerpt from ko1:
See rb_thread_blocking_region() in thread.c.

rb_thread_blocking_region(
rb_blocking_function_t *func, void *data1,
rb_unblock_function_t *ubf, void *data2)

func() is your function which you want to do without GL. YARV
release GL and call func(). If func() returned, YARV acquire GL and
continue ruby program.

ubf (unblocking function) is called when another thread interrupts
this thread with Thread#kill, or main thread exits. You must set
ubf as interrupt function for func(). You must write ubf or ruby
will not exit until func() ends.

2008-11-12
28ERROR

The release notes say you’ve changed from, the One-Click to the ruby-lang.org version, but this page still points to the One-Click

2008-01-18
151TYPO

The sentence just after the code example beginning “class Client” ends with “when if the object is deleted”.

2008-01-18
1OK

Could you please include a few pages on the use of SQLite with Ruby in the 3rd edition of “Programming Ruby”? Or some other database that doesn’t convert all of it’s keys into strings? (You mention MySQL, but it isn’t yet in the index, and the mentions seem to be en passant.)

I would prefer SQLite, because I want to have local db files that aren’t system wide. Even using libdb (nee SleepyCat’s Berkeley DB) would be preferable (though I note that Python access to libdb seems to insist that keys be strings unless you are ordering the DB by record number).

That said, I realize that there doesn’t seem to be much available on the web about using SQLite with Ruby (i.e., I haven’t found anything useful), so it might not be feasible without writing a C interface.

(Dave says: Charles: there’s an Sqlite GEM that gives you a decent interface. The book really doesn’t have time to discuss all available libraries—I’m already in to hernia territory)

2008-01-18
24SUGGEST

FYI: This is only a suggestion. I really like the book. My criticism is meant only to help you make the book better (at least in my eyes).

You could use a more consistent parallel construction when writing about the four parts. That is, start a major paragraph with the PART #. Just skimming the page I can immediately see Parts I, and III, but for II and IV I really have to stop and look to find them. I’m not a great reader and want to find particular technical info without having to read lots of text—so a consistent structure helps me.

The change could be as simple as (I’ll do the whole thing):
In Part I, …;
And Part II, …;
And Part III,…;
And Finally Part IV,…

2008-01-18
786TYPO

“This kind of hands-off manipulate of Ruby programs from within C code is easy, but it has
wo major drawbacks.”

should say “manipulation” and “two”

2008-02-10
42TYPO

In first paragraph of section “Symbols”, “reference to the compass points” should be “refer to the compass points”.

2008-01-27
163SUGGEST

“We could fix this by writing a class which reads the file and yields each successive word.”

Should that be “writing a method” instead?

2008-02-10
29SUGGEST

you should add the “Ruby One-Click Installer for Mac OSX” to your list of osx ruby distributions. see the project on rubyosx.com — furthermore, there is a one-click installer for ruby 1.9 for osx in development, soon to be released on rubyosx.com.

(Dave says: I will when it supports 1.9)

2008-10-14
80TYPO

missing space:

to_enummethod should be to_enum method in the paragraph just above the code example

2008-02-18
123SUGGEST

Putting defined? and the logical operators into one heading is confusing and unnecessary

2008-02-10
89OK

There is no such thing as “8-bit ASCII”. I understand that Ruby has an encoding “ASCII-8BIT”, but this term is going to confuse readers into thinking there is such a thing. You may have to say early what ASCII-8BIT is about (i.e., ASCII with a promise that non-ASCII characters won’t be interpreted).

(Dave says: I believe I go on to explain just that…)

2008-02-10
182ERROR

The bookmark for Unit Testing, under Part I—-Facets of Ruby takes you to page 182, but the chapter actually starts on 181.

2008-07-31
550SUGGEST

The description of the private method Object#remove_instance_variable uses an example which implies that the removed instance variable is set to nil.

In reality this method actually undefines the instance variable and then calling the attribute reader re-defines it.

The example would be better as:

class Dummy
def initialize
@var = 99
end

def remove
remove_instance_variable(:@var)
end

def var_defined?
defined? @var
end
end
d = Dummy.new
d.var_defined? # => “instance-variable”
d.remove # => 99
d.var_defined? # => nil

2008-03-19
229TYPO

typo: esxception

2008-02-18
425TYPO

typo: minnax instead of minmax in method name, also minmax “call template” contains “min” instead of “minmax”.

The “call template” is also wrong for minmax_by and min_by.

2008-02-18
441TYPO

description of identical? method has bogus “in Table 26.3 on the following page” in the text as last sentence.

2008-02-18
442SUGGEST

Description of File.new is bit unclear with respect to “modestring”. The referenced table (26.6 on p. 478) doesn’t talk about encodings, even though the text suggests it will.

Also, what happens with encoding if you use integer as modenum is not explicitly mentioned in the text.

(Dave says: IO hasn’t yet been updated. When it is, the table will contain what you need)

2008-03-10
453ERROR

Return value in “call template” for both world_readable? and world_writable? doesn’t correspond with the return value mentioned in method description. Which one is it, then? “bits or nil” or “true or false”

2008-02-18
1SUGGEST

Would
it be possible to add “next” link to every 1.9 flag in the PDF beta
book? Would make sequential scanning for things changed in 1.9 much
easier. :-)

(Dave says: that turns out to be a tad difficult because of the way the flags are added (don’t ask. I personally just use the search facility in my PDF viewer)

2008-02-25
467TYPO

In description of Hash.compare_by_identity is typo in sentence “… if hey are the object.” Btw, even with s/hey/they/ it doesn’t make much sense to me. How about adding “same”?

2008-02-18
471TYPO

Hash.key — typo in description: “hte” (should be “the”).

2008-02-18
472TYPO

Hash.rassoc description, missing description of what is rassoc looking for: “Searches hsh for the first element whose value is (((blank))), returning…”

2008-02-18
227TYPO

In the first sentence after the header “Source Encoding is Per-File”, build should be built.

2008-02-18
229TYPO

“the the” should be “if the” in the sentence that begins “You have to be careful…”

2008-02-18
224TYPO

Simple typo

Ruby actually comes with more encodings that those shown in the output from this code.

Should be “more encodings than…”

2008-02-18
297SUGGEST

Could you give detailed information on the reserved word undef?

(Dave says: I’ve made a note to document it in the languages chapter)

2008-02-25
346TYPO

Fourth paragraph in “self and Method Calling” section reads “If is can’t find the method in the class, it looks in the class’s super class” … should read “If it”

2008-03-10
348ERROR

IMHO, the graphic on the page should have a link from String.super to Object and another from String.class to Class, but not from String.class to Object.

2008-03-19
56OK

in the to_s method of KaraokeSong it should be:
super + " #{[lyrics]}" but it says super + " [lyrics]"

You just missed the #{} block

Best Regards
Lars Söderström
Sweden

(Dave says: it’s actually correct as is)

2008-03-19
57TYPO

Looks like we’re missing the initial definitions of accessors for Song artist, name and duration.

The text goes straight from “… the first thing we may need is the ability to find out the title and …” to samples/tutclasses_11.rb which shows the accessors being used. It then moves on to describing the ‘attr_reader’ shortcut, but i don’t see the long hand definition anywhere.

2008-03-19
356TYPO

I am learning about meta-programming, and you have a diagram showing anonymous proxy classes that Ruby uses when mixing in a module at the top of page 356 - Figure 23.4

I don’t know if it is a typo or not, but I don’t think both anonymous classes would be anon1, this implies they are the same object. I could see how that could be possible in _this_case, but not if the albumn class inherited from some class that is not Object.

So I think the anon1 that Song now uses as a Proxy class should be called anon2.

Mikel

2008-03-19
796TYPO

End of the second paragraph: …(with other implementations waiting in the wings and ot yet released)

2008-03-10
796TYPO

Fifth paragraph: three problems here.
Rubinius is interesting—it uses the original Matz Ruby parser, but containsa totally different
VM implementation. Its goal it to have code run so fast that it is possible to write the
majority of Ruby’s libraries in Ruby itself (rather than having, for example, the String class
written in C, as it is in MRI). Right now, it looks like they might be able to achieve this,
while will be a major win for portability and extensibility.

2008-03-10
7SUGGEST

There’s no mention of RubyGems in the Contents. It might be good to have the actual word in the Contents somewhere.

2008-03-19
213TYPO

Next to last paragraph, second sentence: “It also provides integration into Ruby so that your programs can access gems are libraries. ” s/b “…as libraries.”

2008-03-19
361TYPO

Other times, though, it isn’t appropriate to use
subclassing, either because we already have to subclass some other class or because or
design esthetic rebels against making something like a song a subclass of a logger.

Typo: “or design esthetic” should read “our design esthetic”

2008-03-19
364TYPO

The return value from Struct.new(…) is a class object. By assigning it to the constant Person,
we can thereafter use Parent as if were any other class.

Typo: “we can thereafter use Parent as if” should read “we can thereafter use Person as if”

2008-03-19
368TYPO

You can also make the turtle raise an lower a pen.
This should read: You can also make the turtle raise and lower a pen.

2008-03-19
218TYPO

Heading:
“Gems Can Be More That Libraries”

2008-03-19
30TYPO

Penultimate paragraph on the page:
"You can do this from source, our you can use a package
management system.

2008-03-19
195TYPO

“As of Ruby 1.9, lock parameters are no longer in the same scope as local variables. This may cause compatibility problems with older code. Run with the -w flag to spot these issues. ”

should be:

“As of Ruby 1.9, block parameters are no longer in the same scope as local variables. This may cause compatibility problems with older code. Run with the -w flag to spot these issues. ”

2008-04-11
62TYPO

There is an extra “the” in the sentence:

“class methods are defined by placing the either the class name or the predefined name self,”

2008-04-11
173TYPO

Last line before last example (tutthreads_14.rb)

“[…]allowing other to US it[…]” should be
“[…]allowing other to USE it[…]”

2008-04-11
263ERROR

samples/web_7.rb

should “target” be “action”?

2008-04-11
62OK
  1. instance_method
  2. class_method (old way)
  3. and another_class_method (new way)
2008-04-11
67OK

sample:tutclasses_32.rb
adding @cleared_balance = balance into initialize method is make it more clear.

2008-04-11
104TYPO

Misspelled word:regaulr -> regular

“Once you use named matches in a particular regaulr expression”

2008-04-11
99TYPO

Last line of penultimate paragraph on the page:
" in which case it matches just before the \
."

2008-04-11
103ERROR

samples/tutstdtypes_46.rb The code need:
a = ‘red ball blue sky’

2008-04-11
407TYPO

The penultimate sentence in the explanation of []= at the top of the page contains “(Prior to
Ruby 1.9, assigning nil deleted the corresponding array element; no it simply assigns nil to them.)” when it should end “now it simply assigns nil to them”.

2008-04-11
49OK

Perhaps there should be mention of the Python-like syntax when introducing printf: the example given towards the bottom of the page could also be written as ‘puts “Number: %5.2f,\
String: %s\
” % [1.23, “hello”]’

(Dave says: I think that would add complexity here)

2008-04-11
48SUGGEST

WHAT SECTION:
"You can provide parameters to the call to yield: these will be passed to the block. Within the
block, you list the names of the arguments to receive these parameters between vertical bars
(| params… |).

def call_block
yield(“hello”, 99)
end
call_block {|str, num| … } "

SUGGESTION:
Provide a working code example for this concept. This idea isn’t clear to me. While I see that you are showing flexibility in the ability to send params to the yield. Using the snippet and trying to understand the description I was not able to create a working example of my own.

2008-04-11
123TYPO

Sentence missing the word “are”. It should be “First, all the rvalues are evaluated…”

Original sentence:
First, all the rvalues evaluated, left to right, and collected into an array (unless thay are
already an array).

2008-04-11
213TYPO

“RUbyGems” should be “RubyGems” in the middle of the page.

2008-04-11
221TYPO

“If Ruby sees the sequence sequence \\xEF\\xBB\\xBF at the start of a source file,”
should be:
" If Ruby sees the sequence \\xEF\\xBB\\xBF at the start of a source file,"

2008-04-11
226OK

The code might be:

  1. encoding: utf-8
    while line = gets
    result = line.gsub(/\\dots/, “…”)
    result = line.gsub(/ . . . /, “…”)
    puts result
    end
2008-04-11
226TYPO

The checking list should start with capitalized letter(list 2 and 3).

2008-04-11
229TYPO

“and the second is the internal incoding.”
should be:
“and the second is the internal encoding.”

2008-04-11
687TYPO

“transcendental functions defined my the math module”
‘my’ should probably be ‘by’

2008-05-23
83SUGGEST

On page 62 (Class Methods), using “self.method_name” is referred to as the “modern idiom” for defining class methods. Page 83 (Blocks for Transactions), however, defines a class method on “File” using the “ClassName.method_name” syntax.

I think it would be better to stick with the “modern idioms”. This may be in other places also (you can use regular expressions (see chapter 6, page 104) to search and replace :).

2008-05-23
123TYPO

Splats and Assignment, first paragraph, “consitutent” should be “constituent”

2008-05-23
359TYPO

2nd to last sentence on the page, missing the word “it”:

By assigning it to the constant Person we can thereafter use Person as if were any other class.

2008-05-23
173ERROR

DEADLOCK! There should be an “unlock” call in the main thread (using “ensure”) of examples “tutthreads_13.rb” and “tutthreads_14.rb”.

2008-07-31
211TYPO

Based on the sentences on the rest of the page, I believe the directory name should be 1.9.0, not 1.9.

% gem environment gemdir
/usr/local/lib/ruby/gems/1.9

2008-05-23
214TYPO

“how to we tell” should be “how do we tell”

Original sentence:
Now that we have both versions installed locally, how to we tell our legacy code to use
the old one while still having our new code use the latest version?

2008-05-23
214TYPO

“it’s” should be “its” since you want the possessive version, not the contraction for “it is”.

Original sentence:
However, calling rake a build utility is to miss it’s true power.

2008-05-23
216TYPO

Second paragraph, “executes” should be “executed”

2008-05-23
116OK

Line 3 of paragraph 5:
At some point you’ll probably want to read ?? on page ?? to see exactly how arguments in

not sure if this counts as erratum or not, but it seems that a page reference is missing… :)

(ps, love the book. many times over.)

(Dave says: this gets fixed as I add new content)

2008-05-23
443OK

It appears that Enumerable’s each_cons and each_slice are identical. If they are, could you make a note in the book that they are synonyms?

(Dave says: they are different: slice never repeats elements from the original array, where cons uses a moving window)

2008-05-23
413OK

I’ve been writing some recursive Ruby 1.9 code lately — I have to be careful to know which methods return new objects and which return references to existing objects. I thought it might help others to point out something interesting about Array#last. ‘last’ with no arguments returns a reference. ‘last’ with arguments returns a new object. On the surface, this seems confusing, but perhaps there is a pattern to be found? Dave, perhaps you could say a few words about this?

(Dave says: these kinds of things are optimizations, rather than part of the language. I wouldn’t rely on them, particularly not if you want to run across multiple Ruby implementations.)

2008-08-19
43TYPO

“the actual numeric values of these contants is irrelevant” -> constants

2008-05-23
43SUGGEST

I really like your motivation and explanation for Symbols… “Symbols are simply constant names that you don’t have to predeclare.” I would tack the following on to that sentence: “…and will be guaranteed to be unique.” This way, you ‘close the loop’ and connect to your previous statement of “the actual numeric values of these constants is irrelevant (as long as they are unique)”

2008-05-23
411OK

a = [ “a”, “b”, “c”, “b” ]; a.find_index(“b”) did not work for me: “ArgumentError: wrong number of arguments(1 for 0)”

%w(a b c b).find_index {|i| i > “a”} does work

(Dave says: are you running a recent 1.9?)

2008-05-23
43OK

Table 3.1 seems to be in the wrong place. Should it not be better to display the table before the heading “Arrays and Hashes”?

(Dave says: we do layout at the very end, so this will get moved at that point)

2008-05-23
593TYPO

2nd line reads “…with a roc which will take from zero to n arguements. ” Proc is missing a P

2008-05-23
104TYPO

The last line of the “Extracting Matches to Local Variables” section ends with “(which macthes am) as $3.” which should be “(which matches am) as $3.”

2008-05-23
64OK

In the Singleton section there is the following explanation for using an instance variable:

“Well, remember we said that just about everything in Ruby is an object? Classes are objects in their own right. Here we’re using an instance variable of the MyLogger object.”

I’m just learning Ruby, but to me it seems that last sentence should be:
“… instance variable of the MyLogger class object.”

And maybe you could add an extra note about the create() method and the @logger variable not being available from the object that create() spits out?

2008-05-23
242ERROR

The definition of the DEFAULT prompt mode seems incorrect:

Download samples/irb_9.rb
IRB.conf[:PROMPT_MODE][:DEFAULT] = { …

Should be:
IRB.conf[:PROMPT][:DEFAULT] = { …

2008-05-23
24SUGGEST

In the description of Part II, it says “creating GUI applications using Tk”, however, the release notes for B 1.03 say that the tk chapter has been removed.

2008-05-23
32TYPO

In the shaded box, titled “The Very Latest Ruby”, the last sentence in the second paragraph should end with “Subversion commands” instead of “CVS commands” as it does now. I’ve also noticed on the ruby-lang.org website, it mentioned that the ruby language developers are using CVS for revision control. Kind of confusing…

2008-05-23
34OK

to get information for a particular method in GC class, you should include the class name as part of the parameter:

suggested fix: ri GC::enable

  1. => will return the correct information for GC::enable method

error found: ri enable

  1. => will return a message stating that they are more than one method matching the request

(Dave says: probably only if you have other gems installed containing an enable method.)

2008-05-23
78TYPO

In the example 2/3 of the way down the page, you write " If a variable appears both in the block and in the surrounding scope", but in the actual code in the .pdf, element and c are only defined inside the block, not outside.

Michael Rogers (mprogers@mac.com)

(Dave says: this section has been rewritten)

2008-05-28
33TYPO

“Leopard (OS X 10.5) come with Ruby 1.8 preinstalled. Both work fine out of the box” Come or comes?, Both what?

2008-06-16
96TYPO

The Complex class extends regular numbers with come convenience methods

should be

The Complex class extends regular numbers with _s_ome convenience methods

2008-06-16
39OK

I’d strongly recommend a mention of Mauricio Fernandez’s fastri as a much improved version of the standard ri

aitch tee tee pee slash slash eigenclass.org/hiki.rb?making+ruby+ri+faster

(Dave says: doesn’t seem to run on 1.9:

dave[RUBY3/Book 0:48:25*] fri String
/usr/local/rubybook/lib/ruby/gems/1.9.0/gems/fastri-0.3.1.1/lib/fastri/util.rb:38:in `require’: no such file to load — rdoc/ri/ri_paths (LoadError)
\tfrom /usr/local/rubybook/lib/ruby/gems/1.9.0/gems/fastri-0.3.1.1/lib/fastri/util.rb:38:in `<top (required)>’
\tfrom /usr/local/rubybook/lib/ruby/gems/1.9.0/gems/fastri-0.3.1.1/bin/fri:6:in `require’
\tfrom /usr/local/rubybook/lib/ruby/gems/1.9.0/gems/fastri-0.3.1.1/bin/fri:6:in `<top (required)>’
\tfrom /usr/local/rubybook/bin/fri:19:in `load’
\tfrom /usr/local/rubybook/bin/fri:19:in `

2008-06-16
798TYPO

“authentification”? Perhaps authentication?

Word also appears on page 886: “APOP authentification”

2008-06-16
105TYPO

“…within and of the ranges…” Something got botched here. Maybe “…within the ranges…” ?

(Dave says: if should be “any of the ranges”)

2008-06-16
58TYPO

In the second paragraph, first sentence there is written “Song object”. This should read “BookInStock object” now that the tutorial has been changed.

(Dave says: I’ve removed the whole section)

2008-06-16
61TYPO

Under the “Writable Attributes” section, in the paragraph right beneath the Java setter/getter example, there is a mention of “song.name”. Instead, this should read “b1.isbn” or “b1.price”.

2008-06-16
67TYPO

Right under the “produces” italized text the line should read:

“Processing data.csv
Total value = 122.07”

Instead of:

“sh: line 0: cd: code/sales.data: No such file or directory”

2008-06-16
30TYPO

“Type typing echo hello at the prompt and hitting enter (or return, depending on your keyboard.”

near the bottom of the page in The Command Prompt section should be …

“Type echo hello at the prompt and hitting enter (or return, depending on your keyboard.”

2008-06-16
30TYPO

OX X in Directories, Folders, and Navigation section should be OS X

2008-06-16
38ERROR

It shows an example of using ri to find the details of the method of GC as an example. Here “ri enable” command gives lots of alternatives and “ri GC.enable” does not work as pointed out in the book. However “ri::enable” works..

I am using ruby 1.9.0.

2008-06-16
31TYPO

C:
projects
time_planner
readme.txt on Windows.

should read …

C:\\projects\\time_planner\\readme.txt on Windows.

2008-06-16
47OK

At the bottom of page 46 it says that keys in a hash must be unique.But in the histogram example in the middle of page 47 you give an example of counting the number of times a key occurs. By rule no key could occur more than once but your example shows the same key occuring 3 times. This is very confusing.

(Dave says: the keys represent the things being counted and the value is the actual count, so each key is unique. I’ve reworded the example.)

2008-06-16
81TYPO

“but, unlink a method, those parameters appear at the start of the both between vertical bars”:
1. “unlink” should be “unlike”
2. Typo “at the start of the both between” (perhaps “both” should be “block”?)

2008-06-16
805TYPO

“via the RSTRING macros.This is a change in Ruby 1.9—prior to this you manipulates the C structure directly.”
1. Need a space before “This is a change”
2. Typo “you manipulates” should be “you manipulate”

2008-06-16
65ERROR

In the code example for class CsvReader, the body of the foreach block contains the following line of code:

@books_in_stock << BookInStock.new(row[“ISBN”], row[“Amount”])

Then in the second paragraph following the class CsvReader example code, the first sentence refers to: “…the ISBN and Price columns,…”.

Perhaps Price should be changed to Amount in the explanation, or “Amount” should be changed to “Price” in the code example?

2008-06-16
57TYPO

Inconsistent reference to Song (from a previous version of the book, IIRC):

“Our experience tells us that during development we’ll be printing out the contents of a Song object many times, and the default formatting leaves something to be desired. Fortunately, Ruby has a standard message, to_s, that it sends to any object it wants to render as a string.
So, when we pass one of our BookInStock objects to puts…”

The text then goes on to define a to_s method on BookInStock, so I think the reference to Song just didn’t get converted over to BookInStock.

2008-06-16
65TYPO

At the end of the page :

“The first, book_in_stock.rb, will contain the definition of the class
BookInStock. The second, csv_reader*, is the source for the CsvReader class. Finally, a third
file, stock_stats.rb is the main driver program.”

  • : You have forgot the .rb to the file name cvs_reader.

Good Day

2008-06-16
73SUGGEST

The opening paragraph on Containers talks about examples where containers (like arrays) would be useful. One of those given is “the people in a class”. I’m a seasoned rubyist, but I still hit a minor mental bump processing that. The previous chapter was all about Ruby Classes, and people new to the language may not immediately discern the different context of class as a group of people getting in training. It would read more clearly if that specific example was changed to “people in a room” or “people in a life raft”.

2008-06-16
61TYPO

Comments in example code on this page and on p.62 says the book price will be discounted by 75% but price will in fact be 75% of the original price i.e. reduction is 25%.

Some typos on p.52, last para above code: “followin” should be “following” and “it’s” should be “its”.

Also last para on p.60 - “The corresponding instance variables are isbn and price. automatically.” Respectively perhaps?

Enjoying Ruby and the book very much, thanks and best wishes,

Michael Drysdale
drysdale@gmail.com

2008-06-16
347SUGGEST

The color schema of class illustrations (lime on yellow) correspponds very poorly with the page boundaries color (a tint of red)

2008-06-30
52TYPO

At the bottom of the page:
“The followin example shows a method calling it’s associated block twice”

should be: “The FOLLOWING example shows a method calling it’s associated block twice”

(missing a G in following)

2008-06-30
58TYPO

Start of second paragraph says:
“Our experience tells us that during development we’ll be printing out the contents of a Song object many times”

should read:
Our experience tells us that during development we’ll be printing out the contents of a BookInStock object many times

(should be BookInStock instead of Song)

2008-06-30
60SUGGEST

When creating the instance of BookInStock:
book = BookInStock.new(“isbn”, 12.34)

change the isbn number to an actual isbn number (perhaps the one for this book). Because when the sample output is shown later on the page:
ISBN = isbn
Price = 12.34

It may seem like puts “ISBN = #{book.isbn}” is just printing out the name of the instance variable, not the value of it (obviously the Price right below it shows that it is printing out the value, but for clarity I think using an actual ISBN would be helpful)

2008-06-30
61TYPO

The last line of the Java code example says:
b.setDuration(calculate_discount(b.getPrice());

It should read:
b.setPrice(calculate_discount(b.getPrice());

(setPrice instead of setDuration, looks like a leftover from the Song example)

2008-06-30
76TYPO

Towards the top of the page, it says:
The first and last methods return the n entries at the head or and of an array without removing them.

should read:
The first and last methods return the n entries at the head or END of an array without removing them.

(‘and’ should be ‘end’)

2008-06-30
657ERROR

String.to_r is not available in the default ruby1.9 installation (ubuntu 7.10) or 1.8.6 (exact versions below).

I have verified this with
ruby 1.9.0 (2007-08-30 patchlevel 0) [i486-linux]
ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]
ruby 1.8.6 (2007-06-07 patchlevel 36) [i486-linux]

This function may just need to be tagged 1.9 since you are most likely using a later version of 1.9.

2008-06-30
108OK

show_regexp(a, /[\\d\\]/) # => see [Design Patterns<<->>page 123]

I think this would actually yield “No match” and not “see [Design Patterns<<>page 123]“. The ”” is not preceeded by a digit.

(Dave says: the actual pattern is [\\d\\-])

2008-06-30
135OK

the final ‘end’ which ends the ‘else’ of the “If and unless expressions” example need to come before table 8.1

Right now Table 8.1 appears with a random ‘end’ statement immediately after it.

(Dave says: we do layout when the content is complete)

2008-06-30
52TYPO

At the bottom of the page: “it’s associated block twice” should be “its associated block twice” (its, not it’s)

2008-06-30
72ERROR

In the text, where you have: “We’ll do that later, in 10 on page 155.”
Shouldn’t this be: “We’ll do that later, in chapter 10 on page 155.”

2008-07-07
428SUGGEST

In the table of contents, the “Array” and similar sections are on the same level than the “Built-in Classes and Modules” section, thus, it is impossible to fold all built-in classes to show only the standard library classes.

The built-in classes should be a subsection of the “Built-in Classes and Modules” section.

Also, the naming in table of contents is somewhat strange, e.g. “Array” is named in the toc “4-1Array”.

In case something is unclear, you can mail me at giga@le-pec.org.

Thanks for your hard work.

2008-10-22
66ERROR

In the book, the output of running the program:

$ ruby stock_stats.rb data.csv

is an error:

produces:
stock_stats.rb:1: undefined method `require_relative’ for main:Object (NoMethodError)

To be clear: this error was included in the book’s text at generation time.

(Dave says: d’oh—the book ran it with ruby 1.8 in error)

2008-07-31
75TYPO

“Ruby comes with a library called GServer than implements basic TCP server functionality.”

Should be:

“Ruby comes with a library called GServer THAT…”

2008-07-31
75TYPO

“Then, when a client connections,”

should be:

Then, when a client CONNECTS,"

2008-07-31
66SUGGEST

In stock_stats.rb, STDERR is used to print the file being processed (STDERR.puts “Processing #{csv_file_name}”). Isn’t it better to use STDOUT?

(Dave says: I use STDERR for status messages, because STDOUT is typically used to pipe real data between programs)

2008-07-31
626TYPO

‘tp’ in the second-to-last line of the description of Process.daemon should be replaced by ‘to’.

2008-07-31
81TYPO

Closing bracket is missing for : “We were
then able to perform comparisons (such as p1 > p2 and even sort an array of Person objects.”

2008-07-31
32TYPO

In the paragraph following the shaded box says:
…we didn’t have to enter the pull path
should say:
…we didn’t have to enter the full path

2008-07-31
72TYPO

Says:
IN the previous chapter we saw that that when
Should say:
In the previous chapter we saw that when

2008-07-31
72TYPO

The bookmark “Inheritance and Messages” does not lead to that section on page 72 but links to the box “Inheritance and Mixins” on page 78

2009-03-30
74TYPO

“We can work out why to_s is available in just about
Ruby object.” should probably be “… just about every Ruby object”

2008-07-31
236TYPO

the word “out” should be “our” in the following text block:

Now let’s look at the library files. We know we’re going to be defining (at least) three
classes. Right now, these classes will be used only inside out command-line program, but
it’s conceivable that other people might want to include one or more of our libraries in their

2008-07-31
243TYPO

last paragraph, second to last sentance:

Using Rake means that the GemSpec will be packaged with a set
of tasks that you can use to build you Gem.

final “you” should be “your”.

2008-07-31
82TYPO

Page 82 references “Back on page 100”, but goes to a different page which doesn’t seem to contain the referenced inject method

2008-07-31
390TYPO

Inside the box at the top of the page, in the third sentence: “a class wih no name” should be “a class with no name”.

2008-07-31
96TYPO

The code uses the Shape class, but the comment refers to the Square class.

2008-07-31
580TYPO

Second sentence of Module#constants:
“With on argu-ment” should be “With one argu-ment”

Also, the parenthetical comment at the end of the sentence is missing ‘)’.

2008-07-31
69SUGGEST

I’m somewhat new to ruby, but not to programming. It looks as though there’s an extra “person2” in the code listing on page 69:

person1 = “Tim”
person2 = person1
person1[0] = ‘J’
puts “person1 is #{person1}”
puts “person2 is #{person2}”
person2

I think that person2 at the end should go away.

2008-07-31
89ERROR

Book says: “Combine unshift and push and you have a first-in first-out (FIFO) queue.” But example below it uses shift instead of unshift (and appears to be correct.) So preceding explanation is in error.

2008-07-31
66TYPO

Simple typo:
“But as you programs grow…” should probable be “But as your programs grow…”

2008-07-31
184SUGGEST

(actually a layout type, but that was not on the list)

The footnote on page 184, concerning primitive Thread operations, is not aligned very nicely.

2008-07-31
73TYPO

“The method superclass method returns the parent of a particular class.”
duplicate use of the word “method” in this sentence.

2008-07-31
122ERROR

“If you want to include the literal characters ] and - within a character class, put the at the
start or escape the with \\”

That sentence on the page is missing something. Put the “what” at the start, or escape with a \\.

2008-07-31
127SUGGEST

The foot note on this pages suggests an exercise to the reader to extend the method to handle Double-Barreld and apostrophied names. I don’t know if it was intentional or not, but the code already handles that. So it’s not much of an exercise ;)

2008-07-31
22SUGGEST

Middle of page: change
“we show the value of expressions as on the same line as the expression”
to
“we show the value of expressions on the same line as the expression”

2008-07-31
22SUGGEST

Below 2nd code sample, text reads:
“Note that if you simply run this program, you wouldn’t see…”

How about:
“Note that if you were to simply run this program, you wouldn’t see…”
or
“Note that if you simply run this program, you won’t see…”

2008-07-31
30TYPO

4th paragraph: “(or return, depending on your keyboard.”

open paren without matching close paren

2008-07-31
30SUGGEST

Last paragraph: change “a graphic tool such as Explorer” to “a graphical tool such as Explorer”

2008-07-31
31TYPO

3rd paragraph: “we’ll just using a single dollar sign” should be “we’ll just use a single dollar sign”

2008-07-31
32TYPO

In code examples on this page, the windows versions of the commands use forward slashes rather than backslashes. I just tried this on a windows xp machine to make sure, and it does not work.

2008-07-31
33TYPO

3rd paragraph: change “use apt-get system” to “use the apt-get system”

2008-07-31
33OK

“MISSING:” tag says, "Currently 1.9 is not available. Autogenerated text on page 20 says this version was built with ruby version 1.9.0.

1.9 is not available as a package. I install via SVN from source

2008-07-31
383TYPO

The last paragraph (a partial) begins:

This example is not particular compelling…

It should be:

This example is not particularly compelling.

2008-07-31
43SUGGEST

Last paragraph, last sentence reads: “When a string containing a newline is output, the \
forces a line break.”

For consistency, how about:
“When a string containing a newline is output, the newline forces a line break.”

2008-07-31
48TYPO

Last paragraph ends with a double period (“..”)

2008-07-31
51OK

After reading the first paragraph on this page, I find myself wondering, “Can the string position be 0? If so, would that evaluate to false in a conditional, even though it matched the regular expression?” Please add a satisfying answer!

Dave says: 0 is not false. We cover conditionals elsewhere

2008-07-31
51OK

Last paragraph, first sentence: “Why are there two kinds of delimiter?”

I’m not sure if “delimiter” should be pluralized here or not…

2008-07-31
52ERROR

3rd paragraph, last sentence reads, “You can think of yield as being something like a method call that calls out to the block associated with the method containing the yield.”

I think it would be more correct if this said, “You can think of yield as being something like a method call that calls out to the block associated with the call to the method containing the yield.”

(added “call to the” to emphasize that the block is associated with a method call, not with the method itself)

2008-07-31
54SUGGEST

5th paragraph: “When we run it with arguments, we can see them getting passed in”

This seems to say that we are getting a behind-the-scenes look at the process of passing them in, which seems a bit confusing to me. How about something like “We can run it to see all the arguments that were passed in” instead?

2008-07-31
55TYPO

2nd-to-last paragraph: “a good first step it to” should be “a good first step is to”

2008-07-31
56SUGGEST

2nd-to-last paragraph, last line: change “by the time that initialize returns” to “by the time initialize returns”

2008-07-31
56TYPO

Last paragraph, end of 2nd line: “the two variables here, isbn and isbn are somehow related" needs a comma after "isbn and isbn”.

2008-07-31
58TYPO

2nd paragraph, 2nd-to-last line: “get it’s string representation” should be “get its string representation”

2008-07-31
58TYPO

3rd paragraph, end of 2nd line: “and then available” should be “are then available”

2008-07-31
58OK

3rd paragraph, last sentence: “each object” doesn’t agree with “those objects”. How about changing “those objects” to “that object”?

(Dave says: correct as stands)

2008-07-31
60SUGGEST

It looks like you’re trying to keep a clean set of numbered “tutclasses_##.rb” files. But it seems a little strange that we have a java class here in an .rb file.

2008-10-22
65SUGGEST

It looks like you’re trying to have a cleanly numbered set of “tutclasses_##.rb” files, but in the example on this page we’re calling the files by one set of names in the text (book_in_stock.rb, csv_reader.rb, and stock_stats.rb) and another set of names in the caption starting each code sample.

I’m very sorry for the inconvenience.)

2008-10-22
65TYPO

In the second code example, the “def total_value_in_stock” line and the comment right above it are indented too much.

2008-07-31
66TYPO

3rd paragraph, 2nd-to-last line: “monlithic” should be “monolithic” and “won;t” should be “won’t”

2008-07-31
66OK

Not sure about this one, but in last line of first paragraph under “Access Control” heading, how about changing “A good rule of thumb is never to…” to “A good rule of thumb is to never…”

(Dave says: I wasn’t raised to arbitrarily split infinitives :)

2008-07-31
68SUGGEST

Last paragraph, 2nd sentence: 2nd use of “may want to” sounds redundant - consider eliminating it.

2008-07-31
69OK

2nd paragraph of “Variables” section, last line: Shouldn’t “string” be capitalized to match the other uses above that are capitalized?

(Dave says: if I’d said “take on the properties of String”, then I’d agree. Here I think lower case is better)

2008-07-31
70SUGGEST

Last paragraph, 3rd line: change “take away that fact that” to “take away the fact that”

2008-07-31
73TYPO

2nd-to-last paragraph, 2nd line: “Now also that” should be “Note also that”

2008-07-31
74OK

I’m curious why “.superclass” is used in the first three code examples on this page, but the fourth uses “.superclass.inspect” - if there’s a reason for this, could you include a short explanation?

(Dave says: try it without :)

2008-07-31
76TYPO

2nd-to-last paragraph: “So, by the time our initialize method finished, our LogServer object will be…”
should be:
“So, by the time our initialize method FINISHES, our LogServer object will be…”

2008-07-31
76SUGGEST

End of 2nd-to-last paragraph: “we start and join to this server.” I understand starting a server, but this has me wondering what it means to “join to” it.

2008-07-31
76TYPO

Last line: “its our code” should be “it’s our code”

2008-07-31
77SUGGEST

First line: change “the last few lines of log file” to something like, “the last few lines of the system log file”

2008-07-31
77ERROR

Start of 2nd paragraph: “The use of the server method” should be, “The use of the serve method” (that’s the name of the method in the code example)

2008-07-31
77TYPO

2nd paragraph, 2nd line: “expects it children” should be “expects its children”

2008-07-31
77OK

2nd paragraph: might it be clearer if “expects its children to implement” was instead something like, “expects its children to override”?

(Dave says: the parent doesn’t contain any implementation, so there’s no overriding)

2008-07-31
77TYPO

End of 3rd paragraph: “we ll” should be “we’ll”

2008-07-31
79SUGGEST

First sentence: “Module constants are named just like class constants, with an initial uppercase letter.”
It looks like they are named with all uppercase letters, not just an initial uppercase letter.

2008-07-31
79SUGGEST

The last paragraph on this page is somewhat confusing when it talks about modules having “instance methods”. If a module can’t have instances, can we talk about it having instance methods? Would modules with “self.” prefixes become class methods when mixed into a class? Is it legal to have “self.” methods within a module? If so, what do they mean if the module is used directly, rather than as a mixin?

This paragraph seems to introduce some comfusing wording and some unanswered questions!

(Dave says: they’ll be answered soon…)

2008-07-31
81SUGGEST

The section “Iterators and the Enumerable Module” seems like it is in the wrong place. It starts: “You’ve probably noticed that the Ruby collection classes support a large number of operations that do various things with the collection: traverse it, sort it, and so on.”
I don’t think that having read up to here, I’m in a position to have noticed that. After all, containers are introduced in earnest later, in Chapter 6.

2008-07-31
82SUGGEST

Last paragraph, 2nd line: change comma after “arithmetic sum” to a semicolon.

2008-07-31
83TYPO

(very minor) Spacing would look more consistent if “( ‘a’..‘m’).sum” were instead “( ‘a’..‘m’ ).sum”

2008-07-31
83OK

The body of the middle method (“observers << obj”) looks wrong to me, since there isn’t a observers= setter method. Should this be “@observer_list << obj” instead? Or should there be a setter? If it’s correct as written, an explanation would help.

(Dave says: it;’s a call to the observers method defined above it)

2008-07-31
85TYPO

2nd-to-last paragraph, 1st line: “In the past, we’re tended to” should be “In the past, WE’VE tended to”

2008-07-31
85TYPO

2nd-to-last line: “if code that uses objects of the child class rely on…” should be “if code that uses objects of the child class relies on…”

2008-07-31
86TYPO

Near top: “Instead need to” should be “Instead WE need to”

2008-07-31
86TYPO

3rd paragraph: “And that’s where a combination of mixins and metaprogramming come to the rescue” should be “And that’s where a combination of mixins and metaprogramming COMES to the rescue”

2008-07-31
86SUGGEST

End of 3rd paragraph: “They let us say”
Right before this the subject was “a combination of mixins and metaprogramming”, so my gut says this should read something like, “This lets us say”, or maybe “these techniques let us say”

2008-07-31
87OK

2nd paragraph: “classes that gives Ruby its power” should be “classes that GIVE Ruby its power”.

(Dave says: I think the subject is singular (not classes))

2008-07-31
87OK

2nd paragraph: change “When paired with collections, these blocks…” to “When paired with collections, blocks…” (‘these’ seems unneccessary)

2008-07-31
89SUGGEST

Last paragraph: “shift and unshift add and remove elements…”
I’m pretty sure shift removes and unshift adds, so how about switching the order of either “shift and unshift” or “add and remove”?

2008-07-31
90OK

With this discussion of arrays vs hashes (aka associative arrays) I’m curious about the implementation of arrays vs that of hashes, and whether I should be mindful of performance implications. For example, if I do something like “a[1000000] = 5” would that create a c-style array in memory with a million and one elements, the first million of which are nil? Or should I think of it more like a hash, performance-wise?

2008-07-31
91SUGGEST

In the last few code samples, the differing numbers of dots (“…..” vs “…”) looks odd to me

2008-07-31
94TYPO

2nd line: “the test unit framework” should be “the TestUnit framework”

2008-07-31
95TYPO

End of 2nd paragraph: “an array or two-element subarrays” should be “an array OF two-element subarrays”

2008-07-31
95OK

2nd code example introduced with: “some Ruby programmers might write this more compactly as”
But this version looks like it doesn’t do the same thing. Its output would be an array of strings, while the sample above would output each string on its own line with no array.

(Dave says: try it…)

2008-07-31
96OK

2nd paragraph, 2nd line: I think this would be clearer if “in the same scope outside the block” were changed to “in the scope outside the block” (removing “same”)

2008-07-31
96OK

3rd paragraph, last line: I think this would make more sense if “square is not defined at that point” were changed to “square is not defined before the block”.

2008-07-31
96TYPO

4th paragraph: “unexpected programs” should be “unexpected problems”

2008-07-31
97OK

Start of “Implementing Errors” section: “A Ruby iterator is simply a method that can invoke a block of code. This isn’t really true (as the ”Blocks for Transactions" section on page 102 explains). How about something a little more descriptive like, “A Ruby iterator is simply a method that invokes a block of code for each item in a set.”

(Dave says: the sentence doesn’t imply that every method that invokes a block is an iterator…)

2008-07-31
98OK

I’m curious about footnote 3’s mention that “the [fibonacci] series is sometimes used in sorting algorithms” - is it used in the analysis of sorting algorithms, or is it somehow used directly by a sorting algorithm?

(Polyphase merges using the Fibonacci numbers to schedule the merges)

2008-07-31
98SUGGEST

2nd paragraph: change “the value passed to the yield” to “the value passed to yield”

2008-07-31
98OK

2nd paragraph describes the ‘each’ method and then an example is given. I feel like we’ve already seen this several times by now.

2008-07-31
99ERROR

3rd paragraph: “starting on page 81 we’ll see how defining an each method can…”
But we’re now on page 99

2008-07-31
99TYPO

4th paragraph, last line: “The following example uses the succ, which increments a string value.” What’s “the” doing here? This sentence is teh suck :)

2008-07-31
100TYPO

Middle of 2nd paragraph: “There’s one final wrinkle”
“final” sounds redundant given its use the the preceding sentence. Also, the wrinkle isn’t really final - the next paragraph, a 1.9 addition, adds another wrinkle!

2008-07-31
99SUGGEST

2nd-to-last paragraph: I think this is saying that either a string or symbol naming the method are equally acceptable when calling inject. It might help if this were made a little more explicit.

2008-07-31
99ERROR

Last sentence: “The thing that uses the iterator is just a block of code associated with this method.” I think to be correct this should say something like, “The thing that uses the iterator is just a block of code associated with A CALL TO this method.”

2008-07-31
101SUGGEST

2nd sentence: change “Instead, they generate” to “Instead, they contain methods that generate”

2008-07-31
101OK

4th paragraph: I’m curious at this point how a method can determine whether or not it has been called without a block. After reading more, I saw that this is discussed and answered on page 103. But there is seems to be brought up as though it just came up there for the first time rather than here, two pages earlier.

2008-07-31
101OK

Last code sample on page: I’m thinking that if I modify a with a call such as, “a[0] = 0” after creating the iterator (with “enum_a = a.each” but before using it (with “enum_a.next”), I will get a different result since I have an iterator that still references the same array a. I think this would fit the description of a closure given a little later. My suggestion is to mention at some point that an Enumerator is a closure and will give this type of behavior (or that it isn’t, if that’s the case).

2008-07-31
101OK

Last paragraph: I had to read this part a couple times, because the earlier text had me expecting this paragraph to say that loop returns an Enumerator if it is called without a block. Instead, if talked about use of Enumerators within the block passed to loop, and made no mention of whether loop could be called without a block. I’m not sure how this should be modified, if at all, but I thought I’d mention it since it interrupted the flow for me somewhat.

2008-07-31
103SUGGEST

End of 1st paragraph, suggested change: “whatever parameters it received” to “whatever parameters it RECEIVES”

2008-07-31
103SUGGEST

2nd paragraph, last line: “responsibility for closing an open file has been passed…”
How about changing “passed” to “shifted”

2008-07-31
103SUGGEST

2nd paragraph, last line: change “user of file objects” to “USERS of file objects”

2008-07-31
103SUGGEST

End of 2nd paragraph: Changing the end of the statement “responsibility…back to the files themselves”
to
“the File class itself”
or
“the File objects themselves”
seems a little more correct

2008-07-31
103OK

3rd paragraph: Twice in this paragraph, we have “file object” instead of “File object”

(Dave says: I’m happy with the way it is—I’m talking generically here)

2008-07-31
103OK

3rd paragraph, 3rd-to-last line: “…if a block is associated with the current method.”
Shouldn’t this be something like: “…if a block is associated with the current method’s invocation.”

2008-07-31
103OK

In code sample, File.new is called. On previous page, File.open was called in the same situation. Wondering if there is a difference between File.new and File.open, and why two different calls are used, or if the two are interchangeable.

(Dave says: we’ve already seen both)

2008-07-31
103SUGGEST

In the code example, a call is made to “block_given?” after the method was just introduced as “Kernel.block_given?”.
I’m wondering at this point if the “Kernel.” prefix is implied, and indeed if Kernel is a central module or class that all the core methods in Ruby belong to, and is therefore implied in many of the method calls we’ve been making up until now.

2008-07-31
103OK

In the code sample, we define a class method “my_open” for the File class. I’m wondering at this point if running this code sample will have the effect of adding a new method to the existing File class supplied with Ruby, leaving the rest of the class working as before.

(Dave says: try it…)

2008-07-31
104TYPO

4th paragraph: “ensure that we closed files even if the code processing that file somehow aborted.”
Should be something more like: “ensure that we closed files even if the code processing THE FILES somehow aborted.”

2008-07-31
104OK

“proc object” is used instead of the capitalized form “Proc object” twice on page 104 and once each on pages 105, 106 and 107. Wondering if this in intentional since we seem to be referring to the Proc class in all these cases…

2008-07-31
104TYPO

End of 4th paragraph: “to the called.” should be “to the caller.”

2008-07-31
104OK

Last paragraph: “Ruby provides not one, but two built-in methods that convert a block to an object. Both lambda and Proc.new…” (Footnote 6 adds that there’s a third, proc, but it is ‘effectively’ deprecated.)

…but, there appears to be another one introduced on page 106: ->
From the description it looks like procs created with -> behave like those created with the lambda method, but are more versatile in the parameters they may accept due to the differing syntax of -> and lambda.

So, that would make three built-in methods, not two (and not counting the deprecated proc method) right?

(Dave says: -> is not a method. Its syntax. Method here means code callable by name, and not technique)

2008-07-31
106TYPO

Middle of page: “It [the parameter list for ->] can take default values, splat args (described on page 137), and block parameters (arguments starting with an ampersand).”

It seems like this should be reworded as, “It can take default values, a splat arg (described on page 137), and a block parameter (argument starting with an ampersand).” unless more than one spat arg is allowed and more than one block parameter is allowed.

2008-07-31
107OK

2nd paragraph, last line: “Because the condition is passed as a block,”

It looks like the condition in the example is passed as a proc, not a block.

2008-07-31
77TYPO

13th paragraph, first line, second phrase: “Do do this, we’ll create a hash object indexed” should be “To do this, we’ll create a hash object indexed”

2008-07-31
111SUGGEST

3rd line: change “convert the string” to “convert EACH string”

2008-07-31
111TYPO

2nd paragraph, line 4: more“complex” (no space between ‘more’ and the double-quote)

2008-07-31
111SUGGEST

End of 2nd paragraph: change comma in “the result will be a float, if you mix floats and complex numbers” to a semicolon.

2008-07-31
113SUGGEST

The sample text in the first heredoc sample would be more correct if “ending” were changed to something like “starting”

2008-07-31
114SUGGEST

2nd paragraph: “We’ll have a lot more to say about encoding in 17 on page 247”

How about adding the word “Chapter” before the “17”

2008-07-31
114TYPO

4th paragraph: “than try to remember these ones.”
Suggested replacement: “than to try to remember these.”

2008-07-31
115SUGGEST

Looks like “Struct” makes an appearance for the first time in this code sample, with no discussion of what it does. I think it’s fairly obvious from context, partly because I remember struct from C and mostly from the output shown. It does make me wonder about the details behind Struct, though.

2008-07-31
116TYPO

Last line of 2nd paragraph: change “component” to “components”

2008-07-31
116SUGGEST

In code sample, I notice we’re calling mins.to_i and secs.to_i
On page 111, we called Integer(v1) in the same situation. Wondering if there’s a difference?

2008-07-31
120SUGGEST

2nd paragraph: “At least one operand of the match operator must be a regular expression.”
I’m wondering what it means if both operands of the match operator are regular expressions, and when one would want to do that. I don’t think I saw an example of this anywhere in this chapter.

2008-07-31
120TYPO

3rd paragraph: “We can use this to write a method…”
How about changing “this” to “these” since I think it refers to the $ variables just introduced.

2008-07-31
120OK

4th paragraph says, “The match also sets the thread-local variables $~ and $1 through $9.”
I’m wondering, what about $&, $` and $’, just introduced in the paragraph above? Are they thread-local?

2008-07-31
121SUGGEST

Last line: “They can also be negated by putting an up arrow after the first colon.”
I’ve never heard a caret referred to as an “up arrow”. How about “caret”?

2008-07-31
123OK

Wondering if the “Posix Character Classes” work only for US encodings, and the “Character Properties” do the equivalent thing for all the supported encodings listed? There is very little description on pg 122 explaining this (two short sentences).

2008-07-31
123OK

In description for [:blank:], does “Blank” mean a single space? And for the descriptions for [:graph:], [:print:], and [:punct:], does “space” mean all whitespace characters?

Dave says: Each matches one character position)

2008-07-31
124SUGGEST

In third, fourth, and last paragraphs, “regular expression” is used as if it means something like, “expression within a regular expression”. Regular expressions were introduced on page 120 as “objects of type Regexp”. This usage sounds a little confusing.

2008-07-31
125SUGGEST

In code sample, the line:
a = ‘red ball blue sky’
is used twice and looks a little redundant.

2008-07-31
125SUGGEST

End of page: for the \\k’name’ notation, there’s no example given. How about changing the ‘mississippi’ example at the top of the next page to use the single quote form?

2008-07-31
126OK

In the discussion toward the bottom of this page, I am wondering, what happens if there is a name collision with pre-existing local variables? Would those local variables simply be overwritten by the ones set by the regular expression?

2008-07-31
127TYPO

5th paragraph: “They may enter DAVE THOMAS, dave thomas, dAvE tHoMas, and we’d like to store is as Dave Thomas.”

Two corrections: add an “or” before “dAvE tHomAs” and change “is” to “it”.

2008-07-31
127SUGGEST

Last sentence: “we’ll have to wait until 23 on page 366 to see why it works.”
Suggestion: “we’ll have to wait until CHAPTER 23 on page 366 to see why it works.”

2008-07-31
127SUGGEST

David Kowis’ comment on the code already handling Double-Barreled names and apostrophes looks to be correct if you’re using dashes separating names and names that have apostrophes in them. If you use underscores and apostrophes that indicate possession, then it doesn’t.

mixed_case(“dave_thomas”) # => “Dave_thomas”
mixed_case(“dave-thomas”) # => “Dave-Thomas”
mixed_case(“dave o’thomas”) # => “Dave O’Thomas”
mixed_case(“dave thomas’s”) # => “Dave Thomas’S”

2008-07-31
128TYPO

First sentence: “You can also give sub and gsub a hash as the replacement parameter, in which case it will look up matched groups…”
Suggestion: “You can also give sub and gsub a hash as the replacement parameter, in which case THEY will look up matched groups…”

( sub(/it/, “they”) )

2008-07-31
128OK

Page 126 talking about numbered variables such as $3, noted that “Once you use named matches in a particular regular expression, Ruby no longer bothers to capture unnamed groups.”

On this page, talking about backslash sequences such as \\3 used within an expression, I assume that same rule holds true?

2008-07-31
130OK

In the code sample we have: md1[1, 2] # => [“12”, “34”]
Interesting notation, and don’t think we’ve seen it before. Worth a mention?

2008-07-31
233TYPO

The third sentence in the paragraph beginning “Ruby has an interesting secret”, change “And than means” to “And that means”.

2008-07-31
152TYPO

As of Ruby 1.9, his is no longer supported. => “his is” ???

2008-07-31
32OK

Under “Variable-Length Argument Lists” heading:
‘Placing an asterisk before the name of the parameter after the “normal” parameters lets you do just that.’
How about: ‘Placing an asterisk before the name of a parameter after the “normal” parameters lets you do just that.’
(change ‘the’ to ‘a’)

(Dave says: I believe ‘the’ is correct)

2008-07-31
132TYPO

Last paragraph ends with a double period..

2008-07-31
133SUGGEST

In the first code example on this page, I am wondering: Is the splat argument being passed automatically in the call to ‘super’ without having to write the argument? This seems to be implied by the text right before the example. Or is it really not being used at all, as its name implies?

2008-07-31
137SUGGEST

First sentence: “Earlier, we saw that if you put an asterisk in front of a formal parameter…”
It isn’t explained what a “formal” parameter is, but from the last sentence in this chapter, on page 139, it looks like it means a parameter in a method’s definition, as opposed to an argument in a call to the method. It might help to add a short statement to make this a little clearer.

2008-07-31
138TYPO

Last paragraph: “Some languages feature keyword arguments — that is, instead of passing arguments in a given order and quantity, you pass the name of the argument with its value, in any order.”
How about “…you pass the name of EACH argument with its value…”

2008-07-31
139ERROR

2nd paragraph: “…as long as they follow any normal argument and precede any array and block arguments.”
I think what is meant is: “…precede any SPLAT and block arguments.”

2008-07-31
142TYPO

Last sentence: “…and teh value of the assignment as it’s last parameter.”
Should be “its”, not “it’s”

2008-07-31
144SUGGEST

2nd paragraph: “It then returns that value as the result of the assignment expression.”
I think this would be much clearer if “that value” were changed to “that rvalue”.

2008-07-31
145OK

“Users of older versions of Ruby should note that these rules have changed in Ruby 1.9.”
This sentence makes me wonder if the rules we are about to read are the new ones after the change, or the old ones before the change. I’m pretty sure it’s the former, but it could be a little clearer.

2008-07-31
146OK

Under “Nested Assignments” header: “Ruby treats these terms as if they were a nested assignment statement.”
I don’t think this statement makes sense. I think it might make more sense if it were changed to something like: “Ruby treats these terms as if they were the left side of a nested assignment statement.”

2008-07-31
148OK

Middle of page: ‘This is almost, but not quite, the same as var = var || “default value”. It differs in that no assignment is made at all if the variable is already set. In pseudo code, this might be written as var = “default value” unless var or as var || var = “default value”.’

I am left wondering: Is there any situation where this would have an effect. I’m having trouble thinking of one. And, this seems like the kind of thing that might end up compiling down to exactly the same machine instructions. Could this be clarified?

(Dave says: it’s subtle and we haven’t covered the ground we need to by this point.)

2008-07-31
148TYPO

Last line: “descendents” should be “descendants”.

2008-07-31
150OK

The definition in table 9.1 for === seems a little lacking, like it describes a common use for the operator, but not what it actually does.

(Dave says: seems the same as for the other operators—if anything it has more information :)

2008-07-31
150SUGGEST

On this page: “if is an expression, not a statement—it returns a value.”
On the next page: “Statement modifiers let you tack conditional statements onto the end of a normal statement.”
And a little farther down: “Because if itself is an expression, you can get really obscure with statements such as” followed by an example of using a statement modifier on an if expression/statement.

I’m left a little confused about statements vs expressions. I would think that if is both a statement and an expression, contrary to what it says on this page (150). Could this language be clarified?

2008-07-31
152SUGGEST

In example at top, change “#{input_line}” to “#{command}” to match the “case command” at the beginning of the example.

2008-07-31
76TYPO

typo - should be your instead of you in 3rd paragraph from bottom

(If you subclass doesn’t need an initialize
method, then there’s no need to do anything

2008-07-31
152SUGGEST

Last paragraph: “Ruby classes are instances of class Class, which defines === to test if the argument is an instance of the class or one of its superclasses.”

This sentence is confusing for a few reasons. Instead of “instance of the class”, how about “instance of the receiver”?
Also, it would make more sense to me if “or one of its superclasses” were changed to “or of one of its subclasses”.
(two changes here: “or” -> “or of” and “superclasses” -> “subclasses”)

2008-07-31
154SUGGEST

2nd paragraph, last line: change “one through three and those between…” to “one through three as well as those between…”

2008-07-31
155TYPO

Before last example: “only those lines that contain a d.” would be more correct if changed to “only those lines that end with a d.”

2008-07-31
157SUGGEST

2nd paragraph: “redo repeats the loop from the start” would be a lot clearer if changed to “redo repeats the current iteration of the loop from the start”

2008-07-31
157SUGGEST

Middle of page: “These keywords can also be used with any of the iterator-based looping mechanisms.”
I’m wondering if the meaning here is actually more general, and these keywords can be used any time in a block that is passed to a method and then run via yield or as a proc.

Or are we really just talking about “iterator-based looping mechanisms”? I can’t think of a way to distinguish in code between an “iterator-based looping mechanism” and some other use of a block.

2008-07-31
157SUGGEST

Last paragraph: “A value may be passed to break and next. When used in conventional loops, it probably makes sense only to do this with break, where it sets the value returned by the loop. (Any value given to next is effectively lost.)”

I’m confused by this. Why is any value passed to next lost? If this is true, why is it possible to pass it a value at all? What if we’re in the last iteration through the loop? Couldn’t next finish things off, and potentially return its argument as the return value of the loop?

2008-07-31
158TYPO

2nd-to-last paragraph: “that is exists” should be “that it exists”

2008-07-31
159OK

Last sentence: should “the scoping of variables with blocks” be “the scoping of variables within blocks”?

2008-07-31
91TYPO

“Do do this” should be “To do this”

2008-07-31
159OK

The semicolon in “do |val; square|” should be a comma.

(Dave says: nope—see the end of the previous page…)

2008-07-31
163TYPO

Footnote 1: “a descendent” should be “a descendant”. Also, this explanation seems to support my comment on page 152 about = and changing "superclasses" there to "subclasses". It's a clearer explanation of = than those on pages 152 and 150.

2008-08-19
168SUGGEST

Top paragraph. This made me wonder, “if the second parameter is not supplied, does catch return nil?” After trying it, it looks like this is exactly what happens.

2008-08-19
168OK

Wondering if an uncaught “throw” is basically equivalent to an unhandled exception? Are they treated the same way by Ruby, with different names to suggest different uses? (errors vs normal control flow)

(Dave says: an uncaught throw raises an exception. They aren’t the same)

2008-08-19
172OK

After testing both examples that use file.each_line and substituting file.each, it looks like they do exactly the same thing. Wondering if there is a difference?

(Dave says: they’re the same method)

2008-08-19
174SUGGEST

Curious about the differing behavior of << shown by the examples on this page, and by the following code:
string = “”
string << 99 << " red balloons\
" # => “c red balloons\

STDOUT << string
STDOUT << 99 << " red balloons\
"

  1. >> c red balloons
  2. >> 99 red balloons
2008-08-19
176SUGGEST

/m at the end of a regular expression makes an appearance here. Looking it up, I see that it makes the dot match newlines. Might be worth a mention, though of course this section is not about regular expressions.

2008-08-19
177OK

2nd paragraph: “…in reality Ruby’s fibers are really just…”
Sounds redundant. Maybe eliminate ‘really’?

(Dave basks in redundancy. Sometimes…)

2008-08-19
180SUGGEST

Code sample: "resp = h.get(‘/’, nil )
The nil isn’t explained, and as it looks to be an optional parameter for a hash of headers with a default of nil, maybe it should be left out.

2008-08-19
181SUGGEST

“Thread Variables” section, talking about “thread-local variables” sounded very similar to “local variables in the scope of the code running in a thread”. I was unsure if this was an entirely new namespace (eg, if in the example there would be a local variable to the thread named mycount).
On trying it out, it looks like these “thread-local variables” are indeed in their own separate namespace (the is no local mycount variable). It would make more intuitive sense to me if these were described more as keys in a Hash attached to a thread, and less as “local variables”.

2008-08-19
181SUGGEST

Suggested change in footnote: for consistency, change “where the outcome changes” to “when the outcome changes”

2008-08-19
182SUGGEST

3rd paragraph: “…an unhandled exception exception simply kills the current thread—all the rest continue to run.”
This is true unless it is the main thread that is terminated, right? In other words, the main thread is not “just another thread”?

2008-08-19
185OK

Attempts to run these examples on my mac causes the following:
-:5: uninitialized constant Mutex (NameError)

Looks like adding “require ‘thread’” fixes it.

(Dave says: works on my Mac)

2008-08-19
186ERROR

Looks like Will Bennett’s note about deadlock for page 173, examples 13 and 14, is talking about page 186 in this version.

2008-08-19
186SUGGEST

Bottom example
Looks like “mutex.sleep 3600” should be “rate_mutex.sleep 3600”

(Wondering if mutex.sleep 3600 is the same as:
mutex.unlock
sleep 3600
mutex.lock

…or is it a little more than that?)

2008-08-19
187SUGGEST

Start of “Running Multiple Processes” section
Suggested additional reason for running multiple processes: maybe you want code to run simultaneously on different processors or cores (since it was mentioned that Ruby threads don’t do this)

2008-08-19
187SUGGEST

Last paragraph: “It returns false if the command was found, but returns an error when it runs. It raises an exception if the command cannot be found.”

How about: “It returns false if the command was found, but returned an error when it ran. It raises an exception if the command could not be found.”

2008-08-19
187SUGGEST

I’m not sure what the “1.9” label next to the last paragraph on this page is referring to.

2008-08-19
189SUGGEST

Wondering: in the examples on this page, how does Process.wait know which process to wait for? I assume it is waiting specificially for a child process of the current process to terminate? And if there are multiple child processes, will it be triggered by the first one to exit, whichever that may be?
In the second example, it looks like it retrieves some data on a child process after the child process has already exited (rather than, say, waiting for the next child process to exit).
Some more explanation of Process.wait could be helpful.

2008-08-19
189ERROR

output from puts “child” doesn’t show up for the bottom example

2008-08-19
191TYPO

3rd paragraph: “check the results are what you expected.”
How about: “check THAT the results are what you expected.”

2008-08-19
192SUGGEST

2nd paragraph of “What is unit testing?” section:
“Fred may write the code with a bug one week…”
How about: “Fred may write code with a bug one week…”

2008-08-19
192SUGGEST

Start of “Assertions == Expected Results” section:
“Test::Unit provides a series of assertions…”
How about changing “series” here to “set” or “variety”

2008-08-19
196SUGGEST

In the example, I’m puzzled why ARGF.read is used as a sample of a method that returns nil( it didn’t when I tried it). Also, the message in the assertion, “Read next line of input”, would seem to make more sense if it described an error - something like, “read call shouldn’t return nil”.

2008-08-19
199SUGGEST

2nd paragraph: “Test::Unit is clever enough to notice that there’s no main program, so it collects up all the test case classes and runs each in turn.
We haven’t been using any main(), such as C and Java have, so I assume ”main program" here means some other executable code?
If I add the line:
puts “Testing… (or not?)”
to a test case, and execute the file, it still runs the tests. So it doesn’t seem to depend on whether there’s a main program or not, unless I’m misunderstanding what a main program is.

2008-08-19
200ERROR

5th paragraph: “It starts by working out the name of the directory from which the test file is run…”
I think this would be more correct if it said, “the location of the test file being run” (as opposed to the current working directory, which may be somewhere else entirely)

2008-08-19
200SUGGEST

Bottom paragraph (as well as the example on the next page) suggests requiring test/unit in a test suite file. However, the next page goes on to say that there’s not much point in creating TestSuite objects. So the test suite file is just a list of statements requiring test cases.
Since the test cases will all require test/unit themselves, I don’t understand why requiring it in the test suite is recommended.

2008-08-19
201SUGGEST

It seems like some other testing libraries, such as RSpec and Shoulda, are gaining significant popularity in the Ruby world. Maybe they’re worth a mention in this chapter?

2008-08-19
202SUGGEST

in the list next to assert_instance_of and assert_kind_of, the first parameter is called ‘klass’. Wondering what this is?

2008-08-19
203ERROR

In the sample debug session, the command is “l 1-9” but the output starts with “[1, 10]” (but still prints lines 1 through 9). When I tried it, I got an output of [1, 9].

2008-08-19
205SUGGEST

3rd paragraph: “…you can use arrow keys (as with Emacs) or vi-style key bindings…”
How about something like, “you can use Emacs-style (including arrow keys) or vi-style key bindings…”

2008-08-19
206SUGGEST

From the irb example, it looks like running a ruby program in irb starts a new thread, and not a new process. Wondering if this is the case?

2008-08-19
206TYPO

2nd caption box: “take at look at all current jobs” should be “take a look at all current jobs”

2008-08-19
208TYPO

Top example: comment has a funny ‘<<’ character rather than ordinary less-than signs.

2008-08-19
210SUGGEST

In the benchmarking example, I’m wondering why the first run is a ‘rehersal’. Should it be considered less reliable than the second run, for some reason?

2008-08-19
73ERROR

My problem may well be that I am still running 1.8.6, but I can’t see why c.say_hello would return two responses. In 1.8.6 at least, it only returns “Hello from #<Child:…>” as seems to be indicated in the text below.

2008-08-19
219SUGGEST

Toward the end of the ARGV section: “make sure you empty the nonfilename arguments from the ARGV array before reading from the files.”

I’m curious if arguments that start with a dash are exempt from this.

2008-08-19
221OK

Last paragraph: “I have my Ruby installed…”)
How about: “I have Ruby installed…”

2008-08-19
222TYPO

Start of “RubyGems Integration”: “RubyGems system makes it easy…”
How about: “THE RubyGems sytem makes it easy…”

2008-08-19
223TYPO

2nd paragraph: “You latest project…”
How about: “Your latest project…”

2008-08-19
223TYPO

2nd paragraph: “let’s you construct” should be “lets you construct”

2008-08-19
223SUGGEST

4th paragraph: “The -r option tells it to search the remote repository.”
Wondering if it should be “…to search remote repositories.” (is more than one possible?)

2008-08-19
223TYPO

4th paragraph: “And -n option says…”
How about: “The -n option says…”

2008-08-19
223TYPO

4th paragraph: “The result show…”
How about: “The result shows…”

2008-08-19
223TYPO

Last paragraph: “First, we see that latest version…”
How about: “First, we see that THE latest version…”

2008-08-19
224SUGGEST

Middle of page: “The most reliable way to find the documents is…”
How about: “The most reliable way to find the documentation is…”

2008-08-19
225TYPO

End of page: ‘xml.preference( “ruby”)’
(minor formatting issue - extra space looks odd)

2008-08-19
226TYPO

2nd paragraph: “the currently Builder” should be “the current Builder”

2008-08-19
227TYPO

2nd paragraph: “15.2” should be “Table 15.2”

2008-08-19
228OK

Wondering why “FileUtils::” prefix shows up in first code sample, but not in the second (for rm command)

(Dave says: because Rake provides rm)

2008-08-19
228TYPO

3rd-to-last paragraph: “Our code uses it’s rm method. We use the Dir class…”
How about: “Our code uses ITS rm method. We use THE Dir class…”
(2 changes)

2008-08-19
228TYPO

“Let’s package this is code as a task”
How about: “Let’s package this code as a task”

2008-08-19
229TYPO

4th paragraph ends with “\\sd.”

2008-08-19
229TYPO

End of 2nd-to-last paragraph: “Here’s for example, is a new task”
How about: “Here, for example, is a new task.”
(“Here’s” -> “Here,” and “.” at end)

2008-08-19
230TYPO

2nd-to-last paragraph: “if your interested” should be “if you’re interested”

2008-08-19
239TYPO

Sidebar is headed ‘require_relative and Ruby 1.8’, but the first sentence refers to Ruby 1.9 (‘In case you’re still running Ruby 1.9,’).

2008-08-19
233TYPO

2nd paragraph: “The double colon (:: is…”
Missing closing paren

2008-08-19
233TYPO

Footnote 2: “a class, such as String is really just…”
How about: “a class, such as String, is really just…”

2008-08-19
234TYPO

Right under “Small Programs” header: “However, it you do this…”
How about: “However, IF you do this…”

2008-08-19
234TYPO

2nd-to-last paragraph: “Here’s a single program…”
How about: “Here’s a simple program…”

2008-08-19
235TYPO

Near end: “…and the last few lines look up each command line argument…”
How about: “…and the last few lines WHICH look up each command line argument…”

2008-08-19
236TYPO

Near top: “effectivey” should be “effectively”

2008-08-19
236TYPO

Near middle: “insode” should be “inside”

2008-08-19
236TYPO

Near middle: “read you code” should be “read YOUR code”

2008-08-19
236TYPO

Last paragraph: “It’s job” should be “Its job”

2008-08-19
200OK

The new 1.9 require_relative feature discussed on page 238 should be mentioned here in the discussion about adding paths in tests to the files being tested!

(Dave says: I’ve rewritten that section)

2008-08-19
238TYPO

Output on this page shows an error.
Shoulda installed Shoulda!
(This also happens on page 240)

2008-08-19
238ERROR

For sample file 10, it looks like we’ve skipped 7, 8 and 9 in the numbering

2008-08-19
239ERROR

The example starting on the bottom of this page should be for the TestFinder class. Instead, it shows the TestOptions class, which we already saw on pages 237-238.

2008-08-19
240ERROR

Error loading shoulda (also on page 238)

2008-08-19
240TYPO

Sample files 13 and 14 - did we skip 12?

2008-08-19
240ERROR

Sample file 13:
#! /usr/local/rubybook/bin/ruby

How about:
#!/usr/bin/env ruby

2008-08-19
241SUGGEST

2nd paragraph: “Now all our files are in place.”
…but we never wrote a test for the Runner class

2008-08-19
241ERROR

Running sample project shows error (undefined method `require_relative’)

2008-08-19
241SUGGEST

2nd-to-last paragraph:
“So we’re really looking for a way to take our little application and install it in a standard way.”

How about:
“So we’re really looking for a standard way to take our little application and install it.”

2008-08-19
241TYPO

Last paragraph: “If puts its libraries” should be “It puts its libraries”

2008-08-19
243SUGGEST

Near top: “…downloaded archive on [url]…”
How about: “…downloaded archive AT [url]…”

2008-08-19
243TYPO

2nd-to-last paragraph, we see both “Gems are also a great way…” and “Gems is the way to go.”
Should the second be “Gems ARE the way to go.”

2008-08-19
243OK

Last paragraph, we see both “…is to use rake” and “Using Rake…”
Should the former be capitalized?

(Dave says: the first use is the command)

2008-08-19
244TYPO

A little below middle of page:
“The s.executables line tells Gems to install anagram command-line script the Gem gets installed on a user’s machine.”

How about: “The s.executables line tells Gems to install THE anagram command-line script WHEN the Gem gets installed on a user’s machine.”

2008-08-19
243TYPO

Bottom: “/Users/dave//code/anagram” has a double slash

2008-08-19
245SUGGEST

Looks like the gem server being discussed is an http server. I’m curious what this does that an ordinary http server doesn’t do (probably something to do with the info you get when listing directories?)
Also, would/do gem commands work if you put a gem file on an ordinary http server instead? If so, what’s the difference in what you can do versus hosting on a gem server?

2008-08-19
245TYPO

Near bottom: “This is particular useful”
Should be: “This is particularly useful”

2008-08-19
246SUGGEST

GitHub is very popular now too, and offers gem hosting. Worth a mention here next to RubyForge?

2008-08-19
246TYPO

In 2nd paragraph we see both, “a rich set of Rake tasks” and “a number of rake tasks”
Looks like inconsistent capitalization

2008-08-19
246TYPO

2nd paragraph: “RUbyForge” should be “RubyForge”

2008-08-19
246TYPO

Last paragraph: “…while other prefer…” should be “…while others prefer…”

2008-08-19
248SUGGEST

3rd paragraph: “In addition, many encodings have aliases…”

I’m wondering if you can ask an Encoding object to list its aliases. (There’s a “MISSING: Aliases” tag - not sure if it’s related to that)

2008-08-19
249TYPO

Right before “What Has Encodings” section: “For UTF-8.” is a sentence by itself that looks like a mistake.

2008-08-19
249TYPO

Last paragraph: “However, unlike Ruby 1.8, If any…”
Don’t think “If” should be capitalized

2008-08-19
250TYPO

Bottom paragraph: “These examples illustrates…”
How about: “These examples illustrate…”

2008-08-19
251OK

2nd paragraph: “If you do, Ruby interprets all characters with codes below 128 as regular ASCII, and all other characters as valid constituents of variable names. This is basically a neat hack, as it allows you to compile a file written in an encoding you don’t know—the characters with the high-order bit set will be assumed to be printable.”

Since this paragraph is talking about binary data, it would make more sense to me if “characters” was replaced with “bytes” throughout.

2008-08-19
251TYPO

Bottom: ‘…either an “coding:” comment…’
How about: ‘…either a “coding:” comment…’

2008-08-19
251SUGGEST

Paragraph near bottom: I’m curious - if a file has both a UTF-8 BOM and a “coding:” comment (that says something other than utf-8) will this cause an error? Or will one take precedence over the other?

2008-08-19
252SUGGEST

Middle paragraph: “…what encoding to use on literal strings and regular expressions”
How about something like: “…what encoding to associate with literal strings and regular expressions”

2008-08-19
252SUGGEST

Middle paragraph: “…literal strings and regular expressions.”
How about: “…literal strings and regular expressions (if they have a top bit set).”

2008-08-19
253SUGGEST

Bottom: “Here we fake that out by creating a ASCII-8BIT string that contains a ISO-8859-1 sequence”
How about: “Here we fake that out by creating an ASCII-8BIT string that contains an ISO-8859-1 sequence”
(would seem to match earlier usage)

2008-08-19
253SUGGEST

Last two paragraphs

First begins: “Because of this, you cannot use encode to convert a sequence of bytes held in an ASCII-8BIT tagged string to some other encoding.”

Second begins: “Finally, you can use encode to convert between two encodings if your source string is ASCII-8BIT.”

It goes on to say we do this by passing a second parameter, but the two sentences above directly contradict one another. This could probably be worded more clearly.

2008-08-19
261SUGGEST

In table 18.1 for “—inspect, —noinspect”:
“Use/don’t use Object#inspect to format output (the default, unless in math mode).”

It is not clear here which of these is the default.

2008-08-19
261SUGGEST

In table 18.1 for “-r load-module”:
Same as ruby -r.

It would be more helpful to say something like:
Same as ruby -r. Like running “require ‘load-module’”.

(Or is it more like running “load ‘load-module’”? Or is there even a difference in this case?)

2008-08-19
261SUGGEST

Last sentence: “Variables you set, methods you define, and classes you create are all remembered and may be used subsequently.”

How about adding a parenthetical “(while in the same session)” to the end

2008-08-19
263SUGGEST

End of “Tab Completion” section talks about needing to load irb/completion library to enable tab completion. On my machine (a mac) this appears to be enabled by default. Maybe it’s different for the standard ruby distribution, but in case it isn’t, I’m noting that I didn’t have to do anything to use tab completion.

2008-08-19
265SUGGEST

3rd paragraph: “For example, to make SIMPLE the default prompt for all your irb sessions…”
How about: “For example, to make SIMPLE the default prompt mode for all your irb sessions…”

2008-08-19
266TYPO

Top: “Because the things you type to irb…”
How about: “Because the things you type into irb…”

2008-08-19
266TYPO

First example:
I’m getting errors when trying to run “block.()” (should this be “block.call()”?

…and the line “time 1000000.times ”cat“.upcase”
(but it works when I add braces to get: “time {1000000.times {”cat“.upcase}}”

2008-08-19
266SUGGEST

(referring to the timing example)
“The next time you start irb, you’ll be able to use this method to get documentation.”

How about something like “…to get benchmarks.” instead

2008-08-19
266SUGGEST

Bottom: “Displays lines n initial and n final lines of backtrace.”
How about: “Displays n initial lines and n final lines of backtrace.”

2008-08-19
267SUGGEST

:MATH_MODE description
“If true, irb runs with the mathn library loaded”

…but loading the mathn library isn’t the same as turning on math mode, is it? There seem to be other things that are different when in math mode.

2008-08-19
269OK

irb_change_binding description:
“If obj is given, it will be used as self in the new binding.”

I’m confused about the case of not passing in a value for obj. When I try this, it doesn’t seem to do anything at all (the same variables that were in scope before are still in scope). Also wondering if self would be nil in this scenario.

(Dave says: if you don;t pass a value, self is unchanged)

2008-08-19
270TYPO

In the definition for the default prompt mode, should the return line (:RETURN => “%s\
”) instead say (:RETURN => “=> %s\
”)?

2008-08-19
272SUGGEST

Why isn’t :SAVE_HISTORY in th list on page 267?

2008-08-19
273TYPO

2nd paragraph: “…some HTML format RDoc output…”
How about: “…some HTML formatted RDoc output…”

2008-08-19
275TYPO

Caption for Figure 19.2, 4th line: “…and in the command for the new method…”
should be: “…and in the COMMENT for the new method…”

2008-08-19
276SUGGEST

Wondering why tags rather than

2008-08-19
276TYPO

End of 2nd paragraph: “stops it being interpreted.”
how about: “stops it FROM being interpreted.”

2008-08-19
276TYPO

Last paragraph: “to stop a comment being associated”
how about: “to stop a comment FROM being associated”

2008-08-19
276SUGGEST

Last paragraph: “method, class, or module.”
How about: “method, class, attribute, or module.”

2008-08-19
277TYPO

In Figure 19.4, the line “return Proc.new |n| n*factor” fails on my setup unless I add braces (“return Proc.new {|n| n*factor}”

2008-08-19
278SUGGEST

Bottom: “Both the following are…”
How about: “Both of the following are…”

2008-08-19
280OK

Description of :nodoc:
This paragraph is awkward. It first says that methods inside a class or module will be omitted, then says that by default, they won’t, and then says that with a modifier, they will. Could be reworded.

(Dave says: It says that modules and classes won’t be omitted, not methods.)

2008-08-19
280SUGGEST

Description of :doc:
Could add, " or a method below a ‘:nodoc: all’" (if indeed this is true)

2008-08-19
281SUGGEST

Description of :title:
Wondering, what’s the title if there’s no :title: directive and no —title command-line parameter. Is there one?

2008-08-19
281SUGGEST

Description for :stopdoc: / :startdoc:
“If you don’t specify a :startdoc: by the end of the container, disables documentation for the entire class or module.”

Should this be, “…for the REST OF THE class or module.”?

2008-08-19
281SUGGEST

Near start of “Adding RDoc to C Extensions”:
“Most C extensions hav an Init_Classname function. RDoc takes this as the class definition— any C comment before the Init_ method will be used as the class’s documentation.”

How about changing “Init_ method” to “Init_ function” to match the earlier usage.

2008-08-19
281SUGGEST

call-seq used twice in the last paragraph on pg 281 and once on page 283 without colons. Other directives have colons by their names.

2008-08-19
282TYPO

Halfway down source in Figure 19.5:
Comments have “Fibonacci.upto(count)” but that was for the method above. This method uses ‘max’, not ‘count’.

2008-08-19
282TYPO

Halfway down source listing in Figure 19.5:
Block version of call sequence is missing a closing pipe character.

2008-08-19
283TYPO

2nd paragraph: “Although RDoc heuristics work well for finding the class and method comments for simple extensions, it doesn’t…”

“it doesn’t” should be “they don’t”

2008-08-19
283TYPO

3rd paragraph: “Finally, it is possible in the Init_ method…”
How about: “Finally, it is possible in the Init function…”

2008-08-19
284OK

At end of Figure 19.6, there is a blank line between the last method and its comment. Wondering if this matters to RDoc?

2008-08-19
285TYPO

4th paragraph: “Files ending .c are…”
How about: “Filenames ending .c are…” (matching usage in the preceding sentence)

2008-08-19
285TYPO

4th paragraph: “If directory names are passed to RDoc, they are scanned recursively for C and Ruby source files only.”

The footnote on page 273 mentions Fortran 77 programs, but Fortran isn’t mentioned here at all…

2008-08-19
285SUGGEST

5th paragraph:
Wondering, if a subdirectory is omitted from a .document file, will it (and all its descendants) be skipped?

2008-08-19
285SUGGEST

Near bottom: “You may find it convenient to write this file in Rdoc format, and then use the :include: directive to incorporate this document into that for the main class.”

How about: “…into the documentation for the main class.”

2008-08-19
286SUGGEST

Near middle: “To add documentation to ri, you need to tell RDoc which output directory to use. For your own use, it’s easiest to use the —ri option.”

How about something like, "…For your own use, it’s easiest to use the —ri option, which installs the documentation into ~/.rdoc/.

2008-08-19
287TYPO

First paragraph below sidebar: “…extract it straight from the command and write it to the user.”
Should be: “…extract it straight from the COMMENT and write it to the user.”

2008-08-19
288TYPO

“…with the RI option set to…”
How about:
“…with the RI environment variable set to…”

2008-08-19
289SUGGEST

2nd-to-last paragraph:
Consider removing parens around last sentence. After all, this sentence introduces the example that immediately follows the paragraph.

2008-08-19
290SUGGEST

“To get really fancy, you can decide to escape only certain HTML elements within a string.” (followed by example)

I wondered, “How do you add more elements to the list to escape?” By trial and error, it looks like additional parameters, each with a string containig a tag name, does the trick. Noting it here in case it’s deemed worth mentioning.

2008-08-19
293TYPO

Top: “…the required level of HTML…”

How about: “…the required version of HTML…”

2008-08-19
293SUGGEST

cgi example:
Wondering, why braces? Didn’t the book say the convention is to use do…end when a block spans multiple lines?

2008-08-19
294OK

Amrita example:
Wondering why the top-level tag is

rather than

(Dave says: ’cos that’s all I’m demoing… :)

2008-08-19
295TYPO

Middle of page, describing erb command:
“If the document is omitted, eruby will read from standard input.”
Change “eruby” to “erb”

2008-08-19
295TYPO

2nd-to-last paragraph has several mistakes:
“The lines starting with the percent sign simply execute the given Ruby In this case, it’s a loop that iterates the line between them, setting The next line contains the sequence <%= number %>, which substitutes in the value of number into the output.”

How about something like: “The lines starting with the percent sign simply execute the given Ruby statements. In this case, it’s a loop that iterates over the line between them, setting the number parameter each time. The middle line contains the sequence <%= number %>, which substitutes the value of number into the output.”

2008-08-19
297SUGGEST

2nd paragraph: “you can’t use the -%> trick to suppress blank lines.”
How about “newlines” instead of “blank lines”?

2008-08-19
297OK

Top paragraph briefly discusses bindings. I’m wondering what is in a Binding object. A hash of the variables? If this isn’t the place to go into that, maybe add a link to the place that is?

2008-08-19
297TYPO

“Cookies” section:
text says, “…by setting the cookies parameter…”
last line of code: “cgi.out(”cookie" => cookie ) {msg}

‘cookies’ or ‘cookie’?

2008-08-19
297TYPO

Start of “Sessions” section:
“We really want session: information that persists…”
How about: “We really want SESSIONS: information that persists…”

2008-08-19
298TYPO

2nd-to-last paragraph: “The filenames will all start web-session. and will end with a hashed version of the session number.”
How about: “The filenames will all start WITH web-session. and will end with a hashed version of the session KEY.”
(Or are ‘session number’ and ‘session_key’ actually two different things here? I didn’t see any other reference to a session number.)

2008-08-19
298TYPO

Last paragraph: “plug in-based”
How about: “plugin-based”?

2008-08-19
300TYPO

2nd paragraph: “Web” is capitalized (but in the first paragraph, it isn’t)

2008-08-19
300TYPO

2nd paragraph: “run your applicate”
How about: “run your application”

2008-08-19
300TYPO

2nd-to-last paragraph: “Merb as a lighter-weight alternative to Rails.”
How about: “Merb IS a lighter-weight alternative to Rails.”

2008-08-19
300TYPO

Last paragraph: “Alternative frameworks include…”
How about: “Other alternative frameworks include…”
(Merb was already mentioned)

2008-08-19
300TYPO

Last paragraph: “By the time your read this…”
How about: “By the time YOU read this…”

2008-08-19
301TYPO

2nd paragraph: “For example, I download the .zip file”
How about: “For example, I DOWNLOADED the .zip file”

2008-08-19
301TYPO

In the sample shell commands, the command setting the PATH appears twice for some reason, and we cd to \\ruby19, which we’re already in

2008-08-19
302OK

4th paragraph: “..generates a PDF file, which the Ruby script downloads into a local file.”
How about “…into a local DIRECTORY.”

2008-08-19
303TYPO

2nd-to-last paragraph: “An OLE object’s parameters are automatically set up as attributes of the WIN32OLE object. This means you can set a parameter by assigning to an object attribute.”

I think the two occurrences of “parameter(s)” here should say “propert(y/ies)”.

2008-08-19
303OK

Last paragraph: “…the sample file excel2.rb”
Is this supposed to refer to one of the samples directly above here, win32_4.rb or win32_5.rb?

(Dave says: it refers to the file in the code download)

2008-08-19
307TYPO

2nd paragraph under “More Help” heading:
“For example, the following code, taken from the DL source code in the standard Ruby distribution, pops up a message box on a Windows machine, and determines which button the user clicked.”

Consider elimating the last comma (after “Windows machine”)

2008-08-19
296TYPO

Last paragraph: “THis” should be “This”

2008-08-19
296TYPO

Last paragraph: “…what Rails does with its .erb/html templates.”

I think “.erb/html” should be “.erb.html”

2008-08-19
82OK

The examples of inject at the top of the page do not work.

(Dave says: The example output is generated by executing code every time the book is formatted…

Maybe you’re using Ruby 1.8?)

2008-08-19
123SUGGEST

You might want to mention somewhere that the posix character classes require double brackets to work: [[:print:]] or at least I think they do. Some examples of using these would be nice.

Also, a more clear definition of “graph”, “printable”, etc as they apply to Ruby strings.

2008-08-19
123OK

Sorry, I see the examples on page 122 of posix, but still having trouble with it. I think maybe [:ascii:] and [:word:] aren’t supported in 1.8.6

Invalid regular expression; [:ascii:] is not a character class: /[[:ascii:]]+/
invalid regular expression; [:word:] is not a character class: /[[:word:]]+/

(Dave says: No - I think these are 1.9 features)

2008-08-19
37TYPO

code illustrating “shebang” includes puts “Hello, world!”, but the output shown is "It is now…….

may be confusing to new folk

2008-08-29
223ERROR

Second half of page says: And -n option … whose name matches the regular expression /builder/.
The example above searches for ‘build’, not ‘builder’. So either example or description should be corrected.

2008-08-19
171OK

The Header is “Reading and Writing File” but the example only shows reading and there is actually no example of File writing

That’s a higher-level heading. The second on writing is contained with in.

2008-08-19
208TYPO

Word missing in first paragraph after “Anyone for Shoulda?”:
You [word missing] much of the descriptive power of RSpec-style expectations without having to commit to the
full framework.

2008-08-29
208TYPO

“Should” should be “Shoulda” in second paragraph under “Anyone for Shoulda?”:
Install Should[a] using gem install Shoulda.

2008-08-29
205TYPO

In the first full paragraph on the page, fourth sentence, unlike LIFE not like.

2008-08-29
60SUGGEST

Integer(price * 100)
Price = 33.8
Price in cents = 3379

To me this just seems wrong. If I am a store owner I would loosing money here… I am sure there is a perfectly fine explanation for this and I think here would be a good place to explain it or at least a foot note detailing where it gets explained. I suspect it is a rounding issue but it does not seem right to me.

2008-08-29
94TYPO

Near bottom: duplicate duplicate “that that”

2008-08-29
101TYPO

Footnote 6: Should “conventially” be “conventionally”?

2008-08-29
91TYPO

Middle paragraph: “…and a block parameter (arguments starting with an ampersand).”
Should “arguments” be plural or singular here?

2008-08-29
141TYPO

Toward end: “Arrays, support this:”
Should this be, “Arrays support this:” (without the comma)?

2008-08-29
157TYPO

Paragraph in middle of page: “they typically make most sense when…”
How about: “they typically make THE most sense when…”

2008-08-29
152OK

Last paragraph: “The === operator is defined in Class to test if the argument is an instance of the receiver or one of its superclasses.”

There seems to be a little ambiguity over whether the last part of this means
“…or if the argument is an instance of one of [the receiver’s] superclasses”
or
“…or if the argument is one of [the receiver’s] superclasses”

2008-08-29
204TYPO

3rd paragraph: “you can even mix Shoulda tests for regular test::Unit test methods.”
How about: “you can even mix Shoulda tests into regular test::Unit test methods.”

2008-08-29
209TYPO

Near bottom: “[1, 9 in t.rb”
Looks like it’s missing a closing bracket…

2008-08-29
243TYPO

Footnote 3: “We talk about Shoulda starting on page ??. For now, you can run this code by installing the gem using gem install Shoulda.”

I don’t know if there’s more on it later in the book (since this footnote was also in the previous version), but Shoulda is now introduced in this version before we get here, and has what looks like it might be the start of a section on page 208.

2008-08-29
245TYPO

Top of “require_relative and Ruby 1.8” sidebar: “you can use still use” (extra ‘use’ in there)

2008-08-29
247TYPO

“Now all our files are in place, we can…”
How about:
“Now THAT all our files are in place, we can…”

2008-08-29
250TYPO

4th-to-last paragraph: “The s.executables line tells Gems to install the anagram command-line script the Gem gets installed on a user’s machine.”
How about:
“The s.executables line tells Gems to install the anagram command-line script WHEN the Gem gets installed on a user’s machine.”

2008-08-29
255TYPO

Near end of “Source Files” section: “For UTF-8. If Ruby sees the byte sequence…”
I’m guessing this should be a comma after “For UTF-8”?

2008-08-29
302TYPO

First paragraph: “…as if the template is eing evaluated…”
Change “eing” to “being”

2008-08-29
447TYPO

in frozen?
“or it it is in” should be “or if it is in”

2008-08-29
211TYPO

“so I;d recommend a quick web search rather.. ”
should be “so I’d recommend a quick web search rather..”

2008-08-29
234TYPO

“HEre we can just use rm”
should be “Here we can just use rm”

2008-08-29
242TYPO

“.. options.rb file inslde a directory named anagram..”
should be “.. options.rb file inside a directory named anagram”

2008-08-29
204TYPO

In the first line, it should be ‘user stories’ instead of ‘user stores’

2008-08-29
253SUGGEST

“Tama” sounds strange to me for a Japanese female name, but for a Japanese cat’s name. Mai, Hana, Yui are much better… I dont know…

2008-08-29
728TYPO

If has a
few incompatibilities with the original.

should read:

It has a
few incompatibilities with the original.

2008-08-29
295ERROR

The description for CGI.escapeElement says; “Here only the A element is escaped; other elements are left alone.” but


element is also escaped.

2008-08-29
534TYPO

In the first sentence on page 534 there is a double ‘an’:

“Modes can be represented an an integer formed by or-ing together values from Table…”.

Perhaps “Modes can be represented by an integer…” is what you want?

Great book. I am thoroughly enjoying it.

2008-08-29
541TYPO

Description of each_byte needs to be separated into two lines. Line reads:
“io.each_byte {| byte | block } →nilio.each_byte → enum” but should be

“io.each_byte {| byte | block } →nil
io.each_byte → enum”

2008-08-29
549TYPO

In the IO#gets section, you have this sentence:(although the setting of $_ is considered ugly, an may be removed in future). The word “an” is probably meant to be “and”.

2008-08-29
376TYPO

(for example, by invoking items.size, the process is surprisingly similar.
should be
(for example, by invoking items.size), the process is surprisingly similar.

2008-08-29
453OK

Appear to be missing ‘sort’ (have ‘sort!), and ’sort_by’ methods.

(Dave says: sort is defined in Enumerable)

2008-08-29
480TYPO

‘each_with_index’ overlaps the description (at least in the pdf).

2008-08-29
391OK

sample code uses attr_reader for defining an accessor method. But I feel that using instance_variable_get method is appropriate in this context.

(Dave says: I don’t agree here. I wouldn’t use instance_variable_get in regular code to define an attribute reader, so I don’t think I’d do it here, either)

2008-08-29
376TYPO

“The ony change—and it’s a vitally important one” should say “The only change—and it’s a vitally important one”

2008-08-29
685ERROR

In 1.8, ‘members’ returns an array of strings rather than an array of symbols. Does this change in 1.9?

2008-08-29
791TYPO

‘tuples may be matched using regular expressions, the classes of their elements,’ s/b ‘…expressions, or …’

2008-08-29
397ERROR

title of “instance_eval and class_eval” on the side panel is linked to page 398, not 397.

2009-03-30
398SUGGEST

When you define a class method in the block of class_eval for MyClass, it become a class method of MyClass. When you define an instance method in the block of instance_eval for an instance, it become an instance method(singleton method). so, paragraph in middle of page is confusing for me.

2008-08-29
50SUGGEST

When describing the ‘|’ character in the regular expression /Perl|Python/, you refer to it as a “pipe character”. “Pipe” describes the character’s use in Unix shell commands (later copied, sort of, in the DOS command line), but doesn’t really properly identify the glyph. Two pages later you refer to the character as a “vertical bar”, describing the syntax for passing parameters to yield blocks; and the Windows Character Map accessory refers to it as a “vertical line”. Either of these two designations is preferable to “pipe”, in my opinion. I’m feeling too lazy right now to track down the official name(s) of this character in the ASCII and Unicode specifications, but I’m quite sure it’s not “pipe”.

2008-08-29
403TYPO

“you application will silently ignore calls to unknown methods in your class.”
should be
“your application will silently ignore calls to unknown methods in your class.”

2008-09-23
403TYPO

“The OpenStructclass is distributed with Ruby.”
should be
“The OpenStruct class is distributed with Ruby.”

2008-09-23
66OK

The code on 66-67 does not work. Error line 11 Csv_reader.

(Dave says: the output in the book is produced by running that code at the time the book is formatted. Do you perhaps need to update your Ruby installation?)

2008-09-23
404SUGGEST

If you explain about MY_CLASS constant in your code, it would be helpful.

(Dave says: actually, the implementation was faulty—I’ve fixed it, and MY_CLASS is no more…)

2008-09-23
404ERROR

“define_method—it’s defined in class Object.”
should be
“define_method—it’s defined in class Module.”

2008-09-23
579TYPO

> Returns the regexp object for the regular expression that cerated match.

s/cerated/created

2008-09-23
648TYPO

> Returns true if obj lines between the start and end of the range.

s/lines/lies

2008-09-23
204SUGGEST

> Then, as you fill in the code, the specs mutate into tests that validate your code meets your expectations.

Revise ‘meets your expectations.’ Pehaps ‘which meets your expectations.’

2008-09-23
407OK

how about adding following codes?
p Example.methods(false)
p Example.instance_methods(false)

2008-09-23
52TYPO

See how the code in the block (puts “In the block”) is executed twice, once for each call to
yield.

should be:

See how the code in the block (puts “In the block”) is executed twice, once for each call to
yield?

The period should be a question mark.

2008-09-23
36SUGGEST

For the really beginers perhaps you should mention how to quit from irb and go back to the command prompt.

2008-09-23
377SUGGEST

The description of the example at the top of the page references “Line 11” but the example code doesn’t have any line numbers listed. It would be helpful if the code was shown with line numbers.

2008-09-23
171OK

The title of the section is Reading/Writing to Files but I don’t see any examples for writing to files? I see it for reading only.

(Dave says: writing is discussed starting on page 173)

2008-09-23
214OK

The example at the bottom of the page does not make sense. It looks like you are trying to make a point about blocks but the examples are the same as your output proves. Yield produces ‘three’.

(Dave says: look carefully at the output…)

2008-09-23
57OK

In the BookInStock class definition on page 57, you convert the price to a floating point number using Float(price). However, the reader is left guessing what this type-conversion does exactly and, more importantly, why you don’t do something like price.to_f and how/why that differs from Float(price). If there is no difference, what is the best practice, and why are there two ways of achieving the same results. (This is something that annoys me in general about Ruby: often the same thing can be achieved in many different ways and it is not always clear why or which alternative should be preferred. If a book like this could shed more light on that, that would be welcome.)

(Dave says: at the top of the page it says: The Float method takes its argu-
ment and converts it to a floating point number,1 terminating the program with an error
if that conversion fails. I don;t want to go into any more detail than that here. There’s no real best practice: to_f and Float do different things, and the choice is contextual)

2008-09-23
59OK

Again this is an example how the same thing can be done in Ruby in many different ways. Either you define accessor methods yourself, or you use the shorthand notation. It is good that the book mentions both possibility, but I suggest adding what the “preferred” policy is. Is it best-practice to always use the shorthand notation? The book doesn’t explicitly state this.

(Dave says: there’s no real best policy, but why type out a long method defiition when a single line will do?)

2008-09-23
62OK

In the example (tutclasses_14.rb) on this page you use the expression
Integer(price * 100)
The reader may wonder what the difference is with
(price * 100).to_i
and which of the two solutions should be preferred.

2008-09-23
67OK

Again, as with so many things in Ruby, two different ways of achieving the same thing. In this case: specifying access control. I suggest that, in addition to explaining the two alternative ways of specifying access cotrol, you give the reader a hint on what the preferred way is (or what you prefered way is) and under what circonstances what alternative should be used.

2008-09-23
74SUGGEST

In Figure 5.1, why is the notation with three dots, for example a[1…3] not illustrated, although it is explained in the text on the previous page. I would suggest adding it to the figure too.

2008-09-23
536TYPO

Description of Integer::even?
“Returns true is int is even.” should be
“Returns true if int is even.”

2008-09-23
38TYPO

“Exist an irb session by typing exit,” should be
“Exit an irb session by typing exit,”

2008-10-14
176TYPO

In the section “Writing to Files”, you don’t actually have an example of writing to a file. You skip right to writing binary data, using <<, and then to the next section, Doing I/O with String.

2008-10-14
456OK

Description of Array#pop could be read to say that pop is new in Ruby 1.9. Should be rewritten somehow to make it clear that pop exists in 1.8, and that only the optional numeric argument is new in 1.9.

2008-10-14
205TYPO

Second paragraph begins:

“A better solution is to assume that your Ruby program is packaged according to the conventions we’ll be discussion in Section 16 on page 245. In this arrangement…”

with the typo occurring at “according to the conventions we’ll be discussion”

2008-10-14
376TYPO

In footnote 1, “the objects class hierarchy” should be “the object’s class hierarchy”

2008-10-14
377TYPO

“The call to Test.new on line 11” should be “The call to Test.new on line 10”

2008-10-14
385TYPO

“When you include a module class Example,” should be “When you include a module IN class Example,”

2008-10-14
211ERROR

`gem install Shoulda` is no longer supported. Instead, please update the instructions for a shoulda install to read:

sudo gem install thoughtbot-shoulda —source=[http gems.github.com]
OR

gem sources -a [http gems.github.com]
sudo gem install thoughtbot-shoulda

I’m trying to convince Tammer to dual publish the gem to rubyforge also, but no luck so far ;-)

NOTE: Substitute the github gem url above for the correct one. This wouldn’t let me submit with embedded URLs.

2008-10-21
486ERROR

Prose description of each_with_object, besides missing the initial ‘C’ in ‘Calls’, makes no sense, compared with the example code. Prose appears to be an alternate description of each_with_index.

2008-10-14
106OK

The description of Enumerable.inject taking an operator and operating successively on the first two elements, etc., is not correct for Ruby 1.8. This example should have a big “1.9” around it.

(Dave says: that would be very confusing, as it would look like the 1.9 part was referring to the text. This whole book is for Ruby 1.9, so the flagging of changes is more a courtesy to the reader)

2008-10-14
147TYPO

In the sentence, “First, all the rvalues are evaluated, left to right, and collected into an array (unless thay are
already an array),” ‘thay’ should be ‘they’.

2008-10-14
453SUGGEST

The special-case description of Array.insert(–1, obj) is confusing and unnecessary, making it seem as if –1 behaves differently from other negative indexes. The behavior where index == –1 is consistent with any other negative index.

Suggested text:

If index is not negative, inserts the given values before the element with the given index.
If index is negative, inserts the values after the element with the given index.

If you want to call particular attention to the behavior with –1, I suggest adding text after the “if negative” sentence, perhaps parenthetically. Something like "This means that if index is –1, the given values are appended to the end of the array, making array.insert(–1, obj) equivalent to array.push(obj):

2008-10-14
448ERROR

Description of []= says,

“(Prior to Ruby 1.9, assigning nil deleted the corresponding array elements; now it simply assigns nil
to them.)”

but, at least in Ruby 1.8.6, it’s not as simple as this.
Some very brief testing shows that the behavior depends on the form of the assignment
array[int] = nil
does, in fact, assign nil to that element
array[start, length] = nil
and
array[range] = nill
do delete the corresponding elements.

2008-10-14
458ERROR

“Equivalent” code for slice! is not actually equivalent.
Pre 1.9, if args is a single integer argument, then
self[*args] = nil
does not delete anything from the array, and according to the book (I don’t have 1.9, so can’t verify this), in 1.9 all argument forms will result in this expression assigning a nil to part of the array.

2008-10-14
540ERROR

Description of merge! omits description of the second form. It’s clear from the code examples that merge! behaves exactly as merge , but operates directly on hsh instead of on a duplicate.

2008-10-14
867TYPO

The description of rb_protect says: “Executes body with the given args and returns nonzero in result if any exception was raised. The value in state corresponds to the various TAG_xxx macros.” (emphasis mine)

However, the declaration of rb_protect in the book doesn’t have a “state” parameter; I’d suggest changing the third parameter (currently “result”) in the declaration to “state” to match the description of the function and the implementation of it in eval.c.

2008-10-14
96SUGGEST

The text contains the following lines:

“We also said that all Ruby objects know how to handle to_s. But we’ve also written our own classes that don’t implement to_s. But we didn’t say how.”

The intent here is to say that our objects don’t explicitly define to_s, but handle it anyway. The above text is not clear.

2008-10-14
457TYPO

“enum.choice( n=1 ) → an_array or nil” did not get updated to reflect the new method name (“sample”).

2008-10-14
478TYPO

reads:
“Matches zero of more directories”
“Matches zero or more directories” — “or” not “of” ?

2008-10-14
703TYPO

This seems wrong if a thread has been killed:

Thread.kill(a) # => #

a.alive? # => true

(Dave says: I added a sleep to give it time to die)

2008-10-14
405TYPO

“For example, we might be wring a simple DSL” should be
“For example, we might be writing a simple DSL”

2008-10-21
405OK

“To draw … 5x5 squares, we might write:

4.times do
forward(4)
left
end”

It seems to me very unlikely that we would be writing “forward(4)” to draw a side of a 5x5 square. To avoid confusion, I suggest either changing “5x5” to “4x4”, or (probably better, to prevent confusion between different uses of the number 4) change “forward(4)” to “forward(5)”

dave[RUBY3/Book 18:21:04*] ruby code/classes/turtle.rb 
#####   #####   #####
#   #   #   #   #   #
#   #   #   #   #   #
#   #   #   #   #   #
#####   #####   #####

2008-10-21
5SUGGEST

It would be useful to have all hierarchies of the TOC in the PDF-TOC as well (for ease of navigation).

2008-10-22
404TYPO

" Previously is was impossible to pass a local or.."
should be
" Previously it was impossible to pass a local or.."

2008-10-21
405TYPO

In Turtle class, “def walk(…) end” should be “def walk(…); end”.

(Dave says: actually, you don’t need the semicolon if there’s a parameter list, but I added it for consistency)

2008-10-21
681SUGGEST

The example code for String#match is either poorly considered or poorly typeset: it is almost impossible to determine the difference between the lower-case “L” characters and the digit “1” in the regex expressions.

Those with prior experience with regular expressions will know what’s what - but that’s not the point.

It wouldn’t be particularly difficult to choose a different example…use ‘greetings’ instead of ‘hello’ and match on the ‘ee’ instead.

2008-10-21
59TYPO

For the code sample “tutclasses_6.rb”, the 3rd books pricing is in speech marks, whereas the previous two books prices are not in speech marks.

2008-10-21
238SUGGEST

Confusing to have Table 15.2’s description “Both the gem…” cut into the middle of the sentence “rake is an automation tool”.

2008-10-20
218TYPO

Closing brace is missed in the phrase “(The $end in the message means end-of-file, so the message simply means that Ruby hit the end of your code before finding all the end keywords it was expecting.”

2008-10-21
205TYPO

Some markup in the middle of the page was not processed by the PDF generation engine: “% ruby -I \\emph{path/to/app} \\emph{path/to/app}/test/test_roman.rb”

2008-10-21
599SUGGEST

Hello Dave,

When describing Module.instance_methods you explain: “Returns an array containing the names of public instance methods in the receiver.” It would be beneficial to point out _explicitly that this includes protected methods as well. I was just rereading and had to test it. :) A small note would have saved me some time.

wee% cat im.rb
module M
def pub; end

def pri; end

def pro; end

public :pub
protected :pro
private :pri
end

p M.instance_methods
wee% ruby -vw ./im.rb
ruby 1.8.7 (2008-08-11 patchlevel 72) [powerpc-darwin9.5.0]
[“pro”, “pub”]

2008-11-12
906SUGGEST

For the PDF version, please include a clickable A-Z list for the Index, as is done in the Rails PDF. I’m not sure what the proper PDF terminology for this is, but in the Preview app on Mac OS, it appears in the sidebar as an outline. The Rails PDF has “Symbols” and “A” through “Z” under “Index,” whereas the Ruby PDF does not. It’s very convenient. Thanks.

(Dave says: your mere wish is my command. I didn’t bother creating a new release, but regenerate your existing PDF and the subentries will appear.)

2008-10-22
702ERROR

Struct::new has two different 1.9 indicators, but as near as I can tell, it’s behavior is unchanged from Ruby 1.8. The block trick has been poorly documented in the past, but I’m pretty sure it’s been there for quite a while (1.8.4 or so maybe). It’s definitely in 1.8.6:

Name = Struct.new(:first, :last) do
def full
“#{first} #{last}”.strip
end
end

p RUBY_VERSION
p Name.new(“James”, “Gray”).full

  1. >> “1.8.6”
  2. >> “James Gray”

(Dave says: the first is indeed incorrect. The second flag is correct, though. In 1.8, #members returned strings, and in 1.9 symbols)

2008-10-23
747SUGGEST

The second bullet point of the CSV description sounds like broken English, though I guess it is technically OK:

“Some CSV files have a header line. Read it, and then process the rest of the file. Auto-matically convert fields that look like numbers.”

I think a little rewording would help there.

Also you are missing some fun of CSV tables on the next page. Try adding these lines to you examples:

p table[:count]
table[:in_stock] = [10, 5, 10, 10]

2008-10-23
712TYPO

The thread.exclusive section is mislabeled as ‘pass’.

2008-10-23
440OK

YAML.dump produces;

—- !ruby/object:Special
precious: World
valuable: Hello
volatile: there

(Dave says: not if you define to_yaml_properties)

2008-11-12
833SUGGEST

The documentation for tmpdir doesn’t cover the new Dir.mktmpdir method.

2008-12-15
507TYPO

“ynonym for each_with_object.”
should be
“Synonym for each_with_object.”

2008-11-12
505TYPO

“alls block with two arguments,…” for each_with_object
should be
“Calls block with two arguments,…”

2008-11-12
774TYPO

1.9 symbol is out of alignment.

2008-11-12
818SUGGEST

You are missing coverage for some nice additions to the shellwords library:

  • shellsplit() is added as an alias for shellwords()
  • shellescape() was added to escape a String for use in Bash
  • shelljoin() was added to escape and join an Array of arguments
  • shellsplit() and shellescape() are added to String and shelljoin() is added to Array for easier access
2008-12-15
368ERROR

Access Control section says, “Private methods therefore can be called only in the defining class and by direct descendents within the same object.” This does not follow from the definition of private methods, and is not true.
Example:

class Parent
def parent_meth
puts “Calling child’s private method”
child_private
end
end

class Child < Parent
private
def child_private
puts “This is the child’s private method”
end
end

child = Child.new
child.parent_meth

####End of example

Even though child_private is being called BY a member of the class within which it’s a private method, it’s being called WITHIN the parent class, not in the defining class or by any descendants. In a sense, Parent here resembles an abstract class in Java, in that it expects (if parent_meth is called) that its child classes will define child_private.

And, of course, this example could be extended to any level of ancestry, with Parent being a grandparent, etc., of Child.

(Same error applies to Programming Ruby, 2nd edition)

2008-11-12
906SUGGEST

Under “#” in the index, please add an entry pointing to the preface where you explain the Classname#methodname notation that you use. I remember when I was reading the previous edition, I kept running across this in the text but couldn’t find the explanation of whether this was a legal Ruby method name or what. I only figured it out when I ran across almost by accident when looking at the preface some time later.

2008-11-12
146ERROR

Error on all Pages…….

On the Footer the “Prepared by …” and the Report Erratum" are overlapping..

2008-11-12
464TYPO

Note in the Array#pack method references String#unpack on page 699. The actual page is 701 and the link sends you to page 689.

2009-03-30
461OK

For the Array Class, the “first” method is defined on page 454 but not described in the following ones (which may be 461).

Hope It Helps ;)

(Dave says: #first is not a method of Array—-it is mixed in from enumerable)

2008-11-12
35OK

“MISSING: MacPorts doesn’t yet have 1.9. Check comment before going to print”

It does - not sure when that changed, but the version I have installed was built in July apparently:
$ sudo -s

  1. port list | grep ruby
  2. port list | grep ruby | grep “1.9.0”
    ruby19 @1.9.0-3 lang/ruby19
  3. port install ruby19
  4. /opt/local/bin/ruby
    ruby 1.9.0 (2008-07-25 revision 18217) [i686-darwin9]

It’s not as recent as building from source, but that’s somewhat expected for MacPorts.

2008-12-15
343TYPO

class variables will are private

2008-11-12
436TYPO

“You can ask it to compile the Ruy code” should be “… Ruby code”

2008-11-12
437TYPO

“Maybe you want to know you Ruby…” should be “Maybe you want to know how Ruby…”

2008-11-12
272ERROR

“The two character sequence ”\\xcf\\x80" represents pi in UTF-8, but is not a valid byte sequence…" should be “The two byte sequence…” (In a chapter about character encodings, it’s important to pedantic around the usage of “bytes” and “characters”.)

2008-11-12
142TYPO

“Get out their and match some strings.”.sub(/their/, “there”)

2008-12-02
64TYPO

Footnote 2:
“When we multiple 33.8 times 100”.sub(/multiple/, multiply)

2008-12-15
64OK

The method “price_in_cents” uses “price”, not “price" (inconsistent with the other uses). I both work, but I presume "price” is a better choice. On the other hand, I’m a Rube, so I could be wrong.

def price_in_cents
Integer(price*100 + 0.5)
end

(Dave says: I prefer using the accessor method: it decouples the code better)

2008-12-15
39TYPO

TIme should read Time.

Context: (Note that the second string contains the text TIme.now between curly braces, and not paren-
theses.)

2008-12-15
339TYPO

at the start of this page, \\d should be \\w.

2008-12-15
466ERROR

a.sample(6) should be something like [“a”, “d”, “c”, “b”]

2008-12-15
498TYPO

at the bottom of page, the description of max_by would be enum.max_by {|item| block } -> obj or enumerator

2008-12-15
562TYPO

At the start of description for `try_convert’, it would be `If obj is not already an io object, …’

2008-12-15
563TYPO

In the description of close_on_exec?, it would be `… close on exec …‘, not `esxec’

2008-12-15
565TYPO

In the description of `getbyte’, it might be `8-bit byte’

2008-12-15
263TYPO

samples/packaging_14.rb class Runner, def run: if no anagrams found, output line should puts “No anagrams in #{word} in #{@options.dictionary}” - missing the @options receiver

2008-12-15
683TYPO

Under String#chars:

< See also CIMString.bytes.
> See also String.bytes.

2008-12-15
505SUGGEST

The documentation for each_with_object is unclear. Where is ‘block’ in the declaration? How can it return ‘memo’ or ‘enumerator’?

The example is pretty good.

2008-12-15
868TYPO

In the first paragraph of ‘Embedding a Ruby Interpreter’ the last sentence begins with ‘Install’, it seems that it should begin with ‘Instead’.

2008-12-15
710ERROR

to_proc for Symbol is defined only in ruby 1.9 (the little “1.9” sign is missing)

2008-12-15
534OK

“Compares fix to other numbers. Fixnum.
<, <=, ==, >=, and >.”

I believe “between?” make the list too.

(Dave says" between? is a methodof Comparable)

2008-12-15
537TYPO

“Compares flt to other numbers. Fixnum.
<, <=, ==, >=, >, and between?.”.sub(“Fixnum”, “Float”)

2008-12-15
209TYPO

“This code assumes soe kind if User class has been written.” should be, “This code assumes some kind of User class has been written.”

2008-12-15
258TYPO

“file inslde a directory named anagram/”.gsub(“inslde”, “inside”)

2008-12-15
261ERROR

packaging_8.rb

It’s great you’re giving a ruby 1.8 version of require_relative. Saddly, it does not always work. Indeed, ‘caller’ returns lines “in the form file:line or file:line: in ‘method’”.

So at least you must modify the grep pattern. I personally think that the code could be improved (‘e’ is not used, I find using $` ugly, File.join not needed, …). Moreover it would be nicer if it was forward compatible to ruby 1.9 (and other libraries doing the same) by checking if it is not already defined. You are welcome to use my version:

module Kernel
def require_relative(relative_feature)
file = caller.first.split(/:\\d/,2).first
if /\\A\\((.*)\\)/ =~ file # eval, etc.
raise LoadError, “require_relative is called in #{$1}”
end
require File.expand_path(relative_feature, File.dirname(file))
end unless method_defined? :require_relative
end

Thanks!

2008-12-15
374SUGGEST

The closure example may be missing a line of code. Specifically, the proc in Creator#create_block should probably start with

puts “CONST = #{CONST}”

A bit more explanation of the example might also be helpful for people who aren’t quite sure what a closure is.

2008-12-17
42ERROR

Just compiled from HEAD. “ri -c” doesn’t list classes, it shows generic help.

(Dave says: I can’t believe they removed that option. Apparently you now run with no options to get the class listing)

2008-12-17
57TYPO

“Here we ask and array”

2008-12-17
57SUGGEST

The current punctuation and sentence structure is hard to discern, at least in the PDF:

“We’ve already come across two methods that do
output. puts writes its arguments, adding a newline after each. print also writes its arguments, but with no newline.”

Since “puts” and “print” begin the sentence, and are lowercase (where we English readers expect a capital), and the font doesn’t differentiate enough, I’d suggest:

“We’ve already come across two methods that do
output: puts writes its arguments, adding a newline after each; print also writes its arguments, but with no newline.”

[Obviously I can’t mimic the differing fonts in this suggestion; but the colon and semi-colon help set off “puts” and “print”]

Indeed, the first sentence is introduction of a list, so I expected a colon following, and read right past the period and into “puts”, and I had to break my scanning to study the paragraph more.

2008-12-17
210TYPO

In the fourth paragraph of “MiniTest::Unit vs. Test::Unit” box, I believe that you want to delete the first “automatically.”

2008-12-17
97OK

The following code:

def power_proc_generator
value = 1
lambda { value += value }
end
power_proc = power_proc_generator
puts power_proc.call
puts power_proc.call
puts power_proc.call

will not produce 2, 4, 8. It produces 2, 2, 2

I think you meant: generator = power_proc
puts generator.call
puts generator.call
puts generator.call

This will produce 2, 4, 8

2009-01-05
90TYPO

“(or it’s synonym enum_for)” should be “(or its synonym enum_for)”. Apostrophe makes it say “it is”.

2009-01-05
92TYPO

“before return a result” -> “before returning a result”

2009-01-05
93SUGGEST

The example at the top of the page has method infinite_select(enum, &block). I believe this is the first time an ampersand is used as a prefix, and there’s no explanation of what it means.

2009-01-05
121SUGGEST

This seems to be the first use of a leading “?” without an explanation of what it does. I’m guessing it’s a way to represent character constants?

2009-01-05
419SUGGEST

The following features are worth to be mentioned in the book :

- simpler way to call a lambda. Ex : my_lambda.(x) instead of my_lambda.call(x)
(I discovered this from Matz Q/A session at RubyConf 2008)
- the constant lookup is no longer lexically scoped. I faced this change in the context of instance_eval.

2009-01-06
134SUGGEST

I know the format isn’t final; however, you may want to ensure the last line, which starts a new paragraph introducing a list (“If r stands for the immediately preceding regular expression within a pattern, then”) is printed with the list without having the reference tables intervening.

2009-01-05
144TYPO

“And we can also use RUby-style comments document the tricky stuff.”

2009-01-05
51TYPO

The phrase “if you’re using a hash to count the number of each different word occurs in a file” is probably missing the word “times.”

2009-01-05
511OK

Enumerator.next, .rewind, .with_index are all ruby 1.9 only, so they should have the little “1.9” tag.

PS: Clearly the 1.9 tag was not automatized, I hope there are not too many such errors.

(Dave says: all of Enumerator is new…)

2009-01-04
511TYPO

Enumerator.each_with_object and its usage line overlap

2009-01-06
179SUGGEST

In Fig 11.1 & Fig 28.1 (ruby exceptions), I think it would be helpful to show which exceptions are new to ruby 1.9. The note on SecurityError changing in the hierarchy could go as a footnote for both figures.

2009-01-05
131TYPO

second line from down in paragraph before ‘Matching Against Patterns’

double time word ‘encoding’

2009-01-05
82OK

puts“#{word}: #{count}”

A bit nicer output : (\\t added)

puts“#{word}:\\t#{count}”

(Dave says: then I’d have to explain \\t, which I don’t do for another 40 pages…)

2009-01-05
21OK

It is a tutorial and reference for version 1.9 of the Ruby programming language.
———————————
It is a tutorial and reference for the version 1.9 of Ruby programming language.

2009-01-04
70OK

Hi,

Atempted to run the code as downloaded in sample form.

Got this error:

om$ ruby stock_stats.rb data.csv
Processing data.csv
/Users/tom/pickaxe/book_in_stock.rb:15:in `Float’: can’t convert nil into Float (TypeError)
\tfrom /Users/tom/pickaxe/book_in_stock.rb:15:in `initialize’
\tfrom /Users/tom/pickaxe/csv_reader.rb:20:in `new’
\tfrom /Users/tom/pickaxe/csv_reader.rb:20:in `block in read_in_csv_data’
\tfrom /opt/local/lib/ruby1.9/1.9.1/csv.rb:1754:in `each’
\tfrom /opt/local/lib/ruby1.9/1.9.1/csv.rb:1190:in `block in foreach’
\tfrom /opt/local/lib/ruby1.9/1.9.1/csv.rb:1328:in `open’
\tfrom /opt/local/lib/ruby1.9/1.9.1/csv.rb:1189:in `foreach’
\tfrom /Users/tom/pickaxe/csv_reader.rb:19:in `read_in_csv_data’
\tfrom stock_stats.rb:15:in `block in


\tfrom stock_stats.rb:13:in `each’
\tfrom stock_stats.rb:13:in `

(Dave says: this is probably a problem in the csv data file: if there are trailing spaces on the header line, then the csv column name will be “Amount ”, and the code won’t find amounts when it looks at each row).

2009-01-05
195OK

“We could fix this by writing a method which reads the file and yields each successive word. But fibers give us a simpler solution.”

I don’t see how using fibers is any simpler than just writing a block that yields each word. In fact, the example looks like you’re doing just that, but wrapping the block in a Fiber object instead of using a Proc. How’s that simpler? I guess I just don’t get it..what’s the real use case for adding fibers to the Ruby language?

2009-01-05
197ERROR

“This code also illustrates a gotcha. Inside the loop, the threads use print to write out the number, rather than puts.”

It uses ‘print’ to output the URL, not a number. Further it uses ‘puts’ to write the “Got:” line; shouldn’t it too use ‘print’?

2009-01-06
35TYPO

“you’ll find the top-level for your C: drive at C:
(that’s the drive letter, C, a colon, and a single backslash).”
The backslash is missing after the second C:. It should be C:\\

2009-01-05
45SUGGEST

“puts –1942.abs” warned me “warning: ambiguous first argument; put parentheses or even spaces”. I added parentheses and it worked correctly — “puts(–1942.abs)”

(Dave says: looks like they’ve tightened that up. Thanks)

2009-01-06
70TYPO

“When designing a class interface, it’s important to consider just how much of you class
you’ll be exposing to the outside world.”
“you class” should be “your class”.

2009-01-16
221TYPO

RSpec sytax -> RSpec syntax

2009-01-16
326TYPO

“Merb is a lighterweight alternative to Rails.”

Use lighter-weight instead. I also note that Merb and Rails is merging, so I dunno if you want to change the statement or not.

2009-01-16
250ERROR

“The —display option…”

It’s not —display, it’s —details

2009-01-16
91TYPO

2nd para: which invokes it’s host class’s each method: its

2009-01-16
593TYPO

sprintf entry starts before spawn entry / options is complete

(Dave says: tables such as this float to the tops of pages. I think I’ll move all tables to the end of the section)

2009-01-16
520TYPO

In absolute_path it looks like “Path names starting with ~ and not expanded, in contract with File#expand_path.” should read:
“Path names starting with ~ are not expanded, in contrast with File#expand_path.”

2009-01-16
497TYPO

In with_object, ‘ynonym’ instead of ‘Synonym’

2009-02-04
21TYPO

Just before Why Ruby?
————————
(such as MacRuby—a version of Ruby
that is integrated into the Objective C runtime on the Mac—only run 1.9 code.
————————
Right parenthesis missing, my Lisp interpreter segfaulted :)

2009-01-21
21TYPO

Footnote 1
—————————-
The hyperlink seems broken
—————————-

2009-01-21
22OK

I am not sure if this is a issue, but I imagine that reading the book in paper it is very ugly to find page 23 starting with an URL.
I would maybe try to get the url back to page 22.

(Dave says: we do layout after the content is complete)

2009-01-21
26TYPO

At the second line of Part III
—————-
the concept of duck typing, the object model model, metapro-
gramming,
—————-
One model too much.

2009-01-21
35OK

Hmm this is a tough one.
You suggest correctly to the reader that he will not want to have a /projects directory. (And sometimes will not be able to have one). But then you continue to use /projects as an example.
As you have already introduced the ~ shortcut for $HOME it might be a good idea to use ~/projects in the unix examples.

2009-01-21
38SUGGEST

Last para before “Source Code”.
Up to here you are walking new and unexperienced users through the first steps of using the command line and installing Ruby. Great Job!!! However, in the aforementioned paragraph you throw a “POSIX systems” on them. Is that not risking to be confusing?

2009-01-21
45ERROR

Second para after samples/intro_1.rb
——————————————————-
Within each class, you can define instance methods. Each method is a chunk of function-
ality that may be called from within the class and (depending on accessibility constraints)
from outside the class.
————————————-
IMHO that should read:
————————————-
…maybe called from within the object …. outside the object.

2009-01-21
46OK

Start of text at p.46
———————————————
Each line shows a method being called as an argument to puts. The thing before the period
is called the receiver, and the name after the period is the method to be invoked.
———————————————
If you have used this wording on purpose, sorry. I however suspect from the context that it somehow slipped in; My suggestion would be:
Each line shows the result of a message sent to an object passed as an
argument to puts. The thing before the period
is called the receiver, and the name after the period is the message sent to the receiver.

(Dave says: I never liked the “message” meme, so try not to use it. But “received” is common parlance, so I go with that flow)

2009-01-21
47SUGGEST

Third para:
—————————-
Having defined the method, we call it twice.
—————————-
Actually this phrase is ambiguous (for beginners only of course).
Suggestion
“call”.clear << “invoke”

2009-01-21
48OK

3rd para
—————————————————-
When Ruby constructs this string object, it looks at the current value of name and substitutes
it into the string.
—————————————————-
… it looks at the current value of name, sends the to_s message to it and substitutes it into…
OR
… it looks at the current value of name, converts it into a string (we will explain this in more detail later, for now it suffices 2 know that it is done in a “natural” way) and substitutes etc.etc.

2009-01-21
53OK

2nd para
——————————-
Most statements in Ruby return a value, …
——————————-
“Most”.clear << “All” and maybe adding that this value can be nil, as e.g. in the case of puts.

(Dave says: what value is returned by “raise”?)

2009-01-21
55OK

para 2 after code example
——————————
The part of a string matched by a regular expression can be replaced with different text
using one of Ruby’s substitution methods.
——————————
This is clearly wrong, but somehow I guess this is done on purpose not to confuse nubies too much. Nevertheless it somehow shocks me, I dunno, just a suggestion:
———————————
The part of a string matched by a regular expression can be replaced with different text
using one of Ruby’s substitution methods.

line.sub(/Perl/, ‘Ruby’) # create a new string in which the first occurrence of ‘Perl’ is replaced with ‘Ruby’
line.gsub(/Python/, ‘Ruby’) # create a new string in which all occurrences of ‘Python’ are replaced with ‘Ruby’

2009-01-21
58ERROR

Last para of “Command Line Arguments”
——————————————————-
the variable ARGF is a special kind of I/O object that
acts like all the contents of all the files whose names are passed on the command line.
——————————————————-
… on the command line or standard input if no arguments were passed.
——————————————
537/38 > echo “xxx” | ruby1.9 -v -e ‘ARGF.each do | line | p line end’
ruby 1.9.1 (2008-12-01 revision 20438) [i686-linux]
“xxx\

2009-02-04
325TYPO

The URL for webrick.org is written with three slashes

2009-02-04
70TYPO

First sentence of first paragraph under Access Control heading:

When designing a class interface, it’s important to consider just how much of you class

should be ‘your’, ‘the’ works also.

2009-02-04
140TYPO

Should say “now know” instead of “know know” in the following sentence:

“This is the second: you know know as much
about regular expressions as the vast majority of Ruby developers.”

2009-02-04
333TYPO

Missing / not rendered bold font in
"Generate the wrapper class using the olegen.rb script in the ext\\win32ole\\samples directory,
giving it the name of the type library to reflect on.

C:\\> \\textbf{ruby olegen.rb ‘NetMeeting 1.1 Type Library’ >netmeeting.rb}

The external methods and events of the type library are written as Ruby methods to the
given file. You can then include it in your programs and call the methods directly. Let’s try
some timings.
…"

2009-02-04
38SUGGEST

Under the “Ruby Programs” header, the name TextMate should have caps. IDE should be defined.

2009-02-04
61ERROR

The leading paragraph states: “…want to accept any object for the price parameter as long as that parameter can be converted to a float. We can pass in a float, an integer, and even a string…” In the example code following, b1 has an integer, b2 has a float, and b3 has another float, rather than a string which would match your text.

2009-02-04
64SUGGEST

The leading paragraph discusses the misconception that attr declarations somehow declare instance variables. This paragraph could end with the sentence: “Ruby completely decouples instance variables and accessor methods as we see in the upcoming section titled ‘Virtual Attributes’.”

2009-02-04
70OK

I think the bottom of pg 70 needs to more strongly emphasize that the default protection of a method is public. I had to reread it a couple times. I think it should state (using ’ to show my insertions): "Ruby gives you three levels of protection ‘using the optional keywords public, protected, and private.’
-Public methods can be called by anyone — no access control is enforced. ‘By default, all methods are public (except for initialize, which is always private) unless the keyword protected or private is explicitly specified’.

2009-02-04
441TYPO

under the heading Behind the Curtain
“As well as being faster that the old interpreter” should read “As well as being faster than the old interpreter”

2009-02-04
145TYPO

“The notation \\k+0> means […]” has one angle bracket too many and should read “The notation \\k<some_letter+0> means […]”

2009-02-04
40ERROR

The downloaded code (in the tar file) does not contain the directory structure or file for fib_example.rb

2009-02-04
97OK

About footnote 7: in Haskell it is implemented as «\\» but there is no way to use it in Ruby since it is reserved.

2009-02-04
210TYPO

Inside this text block:

Folks have been using Test::Unit with Ruby for a good number of years
now. However, the core team decided to replace the testing frame-
work that comes as standard with Rails with something a little leaner.
Ryan Davis and Eric Hodel wrote MiniTest::Unit as a par tial drop-in
replacement for Test::Unit.

… should it say Ruby instead of Rails?

2009-02-04
37TYPO

please add the ruby one-click installer for osx to the options on how to get/install ruby for mac osx. we are providing packages for i386 and ppc for osx leopard, tiger and panther. macruby is not 1.9.1 yet and will only support leopard from version 10.5.2! we support all kinds of osx systems.
( more information on rubyosx.com )

2009-02-04
91TYPO

class String; def please; $stderr.puts “You have done a great job so far”; self end end

para[ –4 ].text.sub( “CEnumerator”, “Enumerator” ).please

2009-02-04
560SUGGEST

Convert int to a rational number.
1.to_r # => 1/1
1.5.to_r # => 3/2
(1.0/3).to_r # => 6004799503160661/18014398509481984

1.5 and 1.0 are not integers so it seems to make no sense to show this examples when describing the Integer class.

2009-02-12
589TYPO

Kernel::loop - Returns an Enumerator if no block given.

I don’t see this behavior.

spitfire% ./irb19
irb(main):001:0> RUBY_DESCRIPTION
=> “ruby 1.9.1p0 (2009-02-02 revision 21960) [i386-freebsd6.3]”
irb(main):002:0> p loop
LocalJumpError: no block given
from (irb):2:in `loop’
from (irb):2
from ./irb19:12:in `

2009-02-12
69ERROR

Fortunately, Ruby comes with a good CSV library (described on
page ??).

This line doesn’t link to anything. Perhaps the page needs to be written still.

2009-02-12
376ERROR

chapter “Proc Objects”, first para last sentence.
There are four ways of converting a block into a Proc object.
——————————————————————————————-
Well there are actually five(1).

def a; Proc::new end
x = a{ 42}
x.call # —> THE Numba

(1) One could argue that this is just a variant of method 1, and I would not disagree too much. In that case however I believe that it is still worth being mentioned.

2009-02-12
657SUGGEST

In the documentation of Proc#lambda? there is a sentence:
See the discussion starting 23 on page 375.
The “23” is a link into page 375 which is within chapter 23, but shouldn’t the text of the link be something like “in Chapter 23”.

2009-02-12
101ERROR

pending from page 100, and referring to Ruby1.8
whereas blocks were basically had just a list of names.
—————————————————————
Splat args were perfectly possible:
515/15 > ruby186 -v -e ‘x=proc{|*args| args.join(“, ”)}; p x.call( :alpha, :centauri )’
ruby 1.8.6 (2009-01-06 patchlevel 291) [i686-linux]
“alpha, centauri”

2009-02-12
340SUGGEST

At the bottom of the page, “You can use the back-
slash escapes shown in 23.2 on the next page.”
The 23.2 is a link to Table 23.2. Other references include the “Table” to make that clear.

2009-02-12
345SUGGEST

At the end of the description of “[characters]”, there is " See 134." where the 134 is a link to that page. The text should say “See page 134.”

2009-02-12
72SUGGEST

2nd para private methods: self is used without prior explanation.
This repeats itself on pp 88, 94, 95 & 103. On page 103 self is eventually explained in a very short term.
————————————————————-
Maybe this is perfectly ok for the level of audience this book is written for. If however it is an oversight I wanted you to give the chance to fix it.

2009-02-12
106SUGGEST

definition of #get_end_of_log_file
Would it not be nicer and in accordance to a suggestion made earlier (p.95) to write the method as follows
File.open(“/var/log/system.log”){ | log |
log.seek(–1000, IO::SEEK_END) # back up 1000 characters from end
log.gets # ignore partial line
log.read # and return rest
}
—————
I know you will prefer do…end but I am part of the, not so small, minority which uses { } for all blocks of which the return value is used and do end for all others.

2009-02-12
563SUGGEST

At the paragraph starting the page:
“See 18 on page 275 for more information.”
Saying “See Chapter 18 ….” would be more clear.

2009-02-12
108OK

module Trig
….
def Trig.sin
etc.etc.
———————————————
An avert reader might remark that this causes problems when one wants to change the module’s name. IOW it’s not DRY

modue Trig
def self.sin
et altri
end

2009-02-12
110OK

First para in Debug#who_am_i?
“#{self.class.name} (\\##{self.object_id}): #{self.to_s}”
————
Suggest to get rid of the superfluous “.to_s”

(Dave says: I want to make it explicit here)

2009-02-12
110ERROR

2nd text para
is:
The Ruby include statement
simply makes a reference to a named module.
——————————-
should be:
The Ruby include statement
simply makes a reference to a module.

2009-02-12
111OK

paras.last
Well I really do not like this sentence:
All you have to do is write an iterator called each, which returns the elements of your collection in turn.
—————————-
If you are happy with it just skip the rest, but maybe you are not either. Are you sure that one can call a method that yields an iterator? If so sorry for wasting your time…

2009-02-12
114OK

Last para before chapter “Resolving Ambiguous …”
A downside of this approach is that the data associated with a particular object will not get
automatically deleted if the object is deleted.
——————————-
Maybe one could add a footnote mentioning that this issue could be solved by a hash holding weak references, which would be a little bit too complex to be shown here.

2009-02-12
121ERROR

First text para
You have three more ways to construct string literals: %q, %Q, and here documents.
%q and %Q start delimited single- and d….
—————————-
As a

2009-02-12
121ERROR

continued
As a matter of fact %Q is rarely used as the Q is optional.
In order for readers to understand codes of others this seems very important.

2009-02-12
121SUGGEST

In the context of string literals.
Maybe it might be noteworthy that " . . . " as well as %[Q]< . . . >
can contain line breaks. A rather unusual feature.

2009-02-12
420TYPO

Missing space in “Ruby 1.9has changed the way Ruby looks up constants when…”

2009-02-12
139TYPO

Under: Pattern-Based substitution, first para:
Reads: We’ve already “see” …
Should Read: We’ve already “seen”

2009-02-12
143TYPO

Under: Controlling Backtracking, 2nd para, line 6:
Reads: the engine goes back and “tried”
Should Read: the engine goes back and “tries”
Or the engine “went” back and tried

2009-02-12
39TYPO

“which claims to offered a packaged OX X […]” should be OS X.

2009-02-12
132OK

Matching Against Patterns
=
1st para:
Once you have a regular expression object, you can match it against a string using the
Regexp#match(string) method or the match operators =~ (positive match) and !~ (negative
match).
—————————————————————-
Regexp#=== is missing in the list above.

(Yes, but that’s not a bug)

2009-02-12
132SUGGEST

last line in code on page
Do not use “ll” but rather “alle” or something more easily distinguishable. At first I did not understand why “11” matches “Fats Waller”. I hate ambiguous fonts.

2009-02-12
133OK

end of first para:
————————————————————-
Given a MatchData object, you can call pre_match to return
the part of the string before the match, post_match for the string after the match, and index using [0] to get the matched portion.
————————————————————
… and to_s or the [] method with parameter 0 to get the matched portion.

There is no MatchData#index method.

2009-02-12
133OK

Last, parenthesized, line:
Actually, \\Z matches the end of a string unless the string ends with a \
, in which case it matches just before the \
.)
——————————————————————
should be:
Actually, \\Z matches the end of a string unless the string ends with a \
and the regular expression is not in Multiline Mode, in which case it matches just before the \
.)
——————————————————
518/21 > ruby19 -ve ‘p( /\\A.*\\Z/m.match( “a\
” ))’
ruby 1.9.1p0 (2009-01-30 revision 21907) [i686-linux]
#<MatchData “a\
”>
robert@siena:~ 17:23:35
519/22 > ruby19 -ve ‘p( /\\A.*\\Z/.match( “a\
” ))’
ruby 1.9.1p0 (2009-01-30 revision 21907) [i686-linux]
#<MatchData “a”>
==
Personally I hate it. It really follows the “implementation” logic and not the “user” logic. Would you care lobbing against this? Please!!! ;)

2009-02-12
134ERROR

Character Classes
=
The significance of the special regular expression characters—
. | ( ) [ { + ^ $ * ?—is turned off inside the brackets.
——————————————-
Not the [ anymore :(

532/36 > ruby19 -ve ‘p( /[[a]/.match( “a[” ))’
ruby 1.9.1p0 (2009-01-30 revision 21907) [i686-linux]
-e:1: premature end of char-class: /[[a]/
534/38 > ruby19 -ve ‘p( /[\\[a]/.match( “[a” ))’
ruby 1.9.1p0 (2009-01-30 revision 21907) [i686-linux]
#<MatchData “[”>

2009-02-12
41TYPO

In the “The very latest Ruby” box,
“You can check files out as an
anonymous user from their archive by executing the following SVN
commands:
$ svn co http:/ /svn.rubylang.
org/repos/ruby/trunk ruby” (sorry had to add a space in the http because of the spam filter here)

There is just one (1) command, so “commands” doesn’t need a “s”.

2009-02-12
46TYPO

Missing reference to “OO Refresher”
—————
“[…] you might want to have a quick look at the notes starting on page ??.”

Maybe this content isn’t written yet? I took a quick look through the index and couldn’t find what it would be….

(Dave says: removed the reference—I had to trim that section for size reasons)

2009-02-12
343ERROR

I don’t think the %s notion to create a symbol is a 1.9 feature. It works in 1.8 as well.

2009-02-12
338OK

Section “General Delimited Input”: Aren’t these so-called “fancy strings”? One could mention this, maybe.

(Dave says: I’ve never heard that term)

2009-02-12
45TYPO

Last line of second paragraph: Shouldn’t it be “mostly everything” instead of “most everything”? Sorry if I’m wrong.

(Most likely.. :)

2009-02-12
503ERROR

Interface for first has two mistakes:
enum.first → int or nil => enum.first → obj or nil
enum.first(⟨n⟩∗) → an_array => enum.first(n) → an_array

2009-02-12
390TYPO

In the section for “to_a”: “a object” instead of “an object”.

2009-02-12
390TYPO

“to_path”: Missing closing parantesis “)” at end of line.

2009-02-12
146TYPO

In the extended regexp’s comment: “palindrone” instead of “palindrome”.

2009-02-12
64SUGGEST

I had initially glossed over the fact that attr_reader is a get-only function. You might want to add a sentence like this -
Note: This is a read-only attribute.

Yes, when you get to attr_accessor and attr_writer, it becomes obvious, but I think others might find this comment helpful…

2009-02-25
767TYPO

“ERB breaks its input text into checks of regular text and program fragments.”

probably meant to say:

“ERB breaks its input text into chunks of regular text and
program fragments.”

2009-02-25
422TYPO

In the last code snippet of the chpater “instance_eval and Domain-Specific Language” there is the instance variable size but in the following three lines explaining the code the instance variable is called count.

2009-02-25
516ERROR

SystemStackError was under StandardError in Ruby 1.8, too! :-)

2009-02-25
245TYPO

In the -E switch documentation: “Specifies
the default character encoding for date read […]”. The word “date” should be “data”, I think.

2009-02-25
245TYPO

Documentation for -E switch: “([…] to this when write, and transcoded from […])”. The word “write” before the comma should be “read”.

2009-02-25
276TYPO

In the first paragraph under “Encodings” in the second line: repeating of word “method”.

2009-02-25
698TYPO

In the table 28.15 (Options to encode and encode!): In the description of :invalid, “If :invalid not …” should be “If :invalid is not …”. Same for :undef.

2009-02-25
245OK

Description of -e option: The programfile has to be ommitted. Even if specified, it is ignored. And ranges of integers don’t match against the current input line nummer. I’ve tested with: echo -e “foo\
bar\
baz\
blih\
blah” | ruby -ne ‘print if 1..2’

(Dave says: I believe this is a Ruby bug)

2009-02-25
452TYPO

In the last line: “The method Object#untrusted? returns true is an object is untrusted.”. Replace the first “is” with “if”.

2009-02-25
301OK

Text under figure doesn’t have serifes.

(Dave says: it’s the caption…)

2009-02-25
302OK

Text under figure doesn’t have serifes. Same for page 303.

(Dave says: it’s the caption)

2009-02-25
270OK

“Gems gets around this issue.” should be “Gems get around this issue.”

(Dave says: ‘Gems’ is singular—it is RubyGems)

2009-02-25
883TYPO

reutns
Once our sum has been calculated, we need to get it back into our C code. The call to
rb_gv_get gets the value of a global variable, but reutns it as a Ruby object. We use NUM2INT
to convert it to a native integer before printing the result (which is 55).

2009-02-25
153OK

The heading “Method Return Values” should be “Methods Return Values”.

2009-02-25
790OK

(The following example would be better written using fibers.)
———————————————————————-
I do not see how fibers can have synchronization issues?
When a fiber yields it cannot wait on a CV at the same time? Or do I miss something here?

2009-02-25
791TYPO

page.paras[1].sentences[–1].sub( “tothe”, “to the” )
—————————————————————————-
I know this is embarrassing, but it is like Python, whitespace matters ;)

2009-02-25
400OK

Third para after code
———————————
Ruby makes this singleton class the class of the “cat” object, and makes String (which was
the original class of “cat”) the superclass of the singleton class. This is shown in Figure 25.2
on the following page.
————————————————-
Unfortunately that is not “true”: Maybe the bug is rather in Ruby than in the book, you decide, but here is what Ruby tells me:
robert@siena:~/SW/ruby-1.9.1-p0 19:02:00
491/3 > ruby -v -e ‘animal=“cat”; class << animal; def a; 42 end end; p animal.class; p animal.a’
ruby 1.9.1p0 (2009-01-30 revision 21907) [i686-linux]
String
42
robert@siena:~/SW/ruby-1.9.1-p0 19:02:42
492/4 > ruby -v -e ‘animal=“cat”; def animal.a; 42 end; p animal.class; p animal.a’
ruby 1.9.1p0 (2009-01-30 revision 21907) [i686-linux]
String
42

BTW the following holds too
494/6 > ruby -v -e ‘animal=“cat”; p animal.is_a?( class << animal; self; end )’
ruby 1.9.1p0 (2009-01-30 revision 21907) [i686-linux]
true

(Dave says: singleton classes are not revealed by .class)

2009-02-25
402TYPO

Last sentence of third para
The class in inserted…
————————————-
The class is inserted

2009-02-25
414OK

code at top of page
module ClassMethods

def self.included(host_class)
host_class.extend(ClassMethods)
end
——————————————-
I feel that
host_class could be named host_module which is more general and that
host_module.extend ClassMethods
could be rewritten as
host_module.extend self
which seems to be more in the spirit how you wrote code in this section. ( And dryer of course!)

2009-02-25
377TYPO

About 12th line from the top:
It says: “Procs, , break, and next”. There are two commas one after each other.

2009-02-25
397TYPO

In a paragraph “self and Method Calling”, at end of 4th sentence, missing closing parantesis.

2009-02-25
280SUGGEST

The first sentence in the “Eight-bit Clean Encodings” section (see below) uses the word “made-up” which denotes “imaginary” colloquially but may denote “consists of” technically to non-native English speakers.

I would suggest changing “made-up” into “imaginary” to avoid confusion.

“Ruby supports a made-up encoding called ASCII-8BIT.”

becomes:

“Ruby supports an imaginary encoding called ASCII-8BIT.”

2009-02-25
410TYPO

“to” should be “too” in “class methods in a parent class are available to in the child class.” (or just strike “to”).

2009-02-25
424OK

first para of chapter “method_missing” hook.
However, Ruby predefines its own version of method_missing in class Object, so typically the search stops there.
———————————————————————————
That seems not to be true:

516/17 > ruby -v -e ‘p Object.instance_method( :instance_eval )’
ruby 1.9.1p0 (2009-01-30 revision 21907) [i686-linux]
#<UnboundMethod: Object(BasicObject)#instance_eval>

However there are two issues with this right now:
Bug #1185 & Bug #1186

2009-02-25
424ERROR

Sorry, wrong copy and paste in the previous post:
Here is what you need:

579/84 > ruby -v -e ‘p BasicObject.instance_method( :method_missing )’
ruby 1.9.1p0 (2009-01-30 revision 21907) [i686-linux]
#<UnboundMethod: BasicObject#method_missing>

2009-02-25
441ERROR

samples/ospace_21.rb contains a call to Kernel.proc which you discouraged the use of earlier in the book (page 376, footnote #7).

2009-02-25
307ffSUGGEST

IMHO it isn’t clear from the descriptions of rdoc’s directives that those directives are not parsed when being put into an included text file, i.e. you cannot put the :main: directive into README.TXT, which seems natural somehow, but only into a ruby file.

2009-02-25
365TYPO

line 1 paragraph 4 reads ‘In Ruby 1.9, arguments with …’ should read ‘In Ruby 1.9, arguments without default values may appear after arguments with defaults.’

2009-03-04
338ERROR

In the discussion of to_ary at the bottom of the page, it says that Ruby 1.9 uses to_splat to do implicit conversion instead of to_ary.

While this was true for a while during the Ruby 1.9/1.9.0 period, Matz undid that experiment and Ruby 1.9 still uses to_ary. Grepping the Ruby 1.9 source code for to_splat finds no hits.

(Dave says: good catch)

2009-03-04
92TYPO

Just under the first code example on the page “But what it you wanted” should be “But what if you wanted” ##Notice the it should be if##

2009-03-04
141OK

str.gsub(/\\\\/, ‘\\\\\\\\\\\\\\\\’) # => “a\\\\b\\\\c” (ruby 1.9.1p0 (2009-01-30 revision 21907)

(Dave says: youre in irb, right? It displays strings in #inspect format by default)

2009-03-04
41TYPO

Shouldn’t the last word in the “The Very Latest Ruby” gray box be “command” rather than “comment”?

2009-03-04
245OK

—disable-gems isn’t included in the list produced by ruby -h for ruby 1.9.1p0 (2009-01-30 revision 21907)

(Dave says: this is bug in Ruby)

2009-03-04
246OK

-U isn’t included in the list produced by ruby -h for ruby 1.9.1p0 (2009-01-30 revision 21907)

(Dave says: this is a bug in Ruby)

2009-03-04
247OK

-X and -y, -yydebug aren’t included in the list produced by ruby -v for ruby 1.9.1p0 (2009-01-30 revision 21907)

(Dave says: this is a bug in Ruby)

2009-03-04
344TYPO

“This second contains” perhaps should be either “This section contains” or “This second section contains”.

2009-03-04
123SUGGEST

samples/tutstdtypes_23.rb and surrounding text look like the first place the notion of “Struct” is used. (Moreover, there is no explanation of what a Struct is at that point in the text). This was a foreign concept when I got to that point in the text on first reading. A little googling and searching in the Pickaxe book made clear what a Struct is, but you might want to add a brief explanation or use another programming concept at that point.

2009-03-04
211TYPO

In the bottom of gray box in the ordered list number 3 starts with “You’ll can install” and it should be “You can install”.

2009-03-04
864TYPO

There is a sentence “When the function terminates.” that makes no sense in the context. Should it have a comma instead of a full-stop?
This occurs in the paragraph that begins “Internally, rb_tbr releases the GVL, then calls the function you specify”.

2009-03-30
857SUGGEST

Dot-point 3 of “Building Our Extension” says “This is what happens on an OS X system.” The way its worded and with the full-stop at the end gave me the impression that you can only build extensions on OS X, rather than the example output happening to be the OS X version of running make. Perhaps say “If run on an OS X system, this is what would happen”

2009-03-30
65TYPO

In the last sentence of the first paragraph: “…as we’ll see [in] the section….”

2009-03-30
295DEFER

The irb configuration options list prompt_i, prompt_c, and prompt_s. There is no mention of prompt_n, though. It took me a while to find a way to format the inner lines of method definitiions.

2009-03-30I hand't come across prompt_n. I'll have to spend some time adding that throughout the chapter.
450SUGGEST

in samples/taint2.rb
do not use
f.open
f.print
f.close
but the blockform of open.

2009-03-30
451ERROR

2nd para
The safe level in effect when a Proc object is created is stored with that object. The safe
level may be set during the execution of a proc object without affecting the safe level of the
code that invoked tha proc. A proc may not be passed to a method if it is tainted and the
current safe level is greater than that in effect when the block was created.

Seems this holds only for $SAFE=4, look at this please:
for i in 1 2 3 4 ; do
> ruby -ve ‘x=lambda{ p $SAFE }.taint;p x.tainted?; $SAFE=’$i’; def a; yield end; a(&x)’
> done
ruby 1.9.1p0 (2009-01-30 revision 21907) [i686-linux]
true
1
ruby 1.9.1p0 (2009-01-30 revision 21907) [i686-linux]
true
2
ruby 1.9.1p0 (2009-01-30 revision 21907) [i686-linux]
true
-e:1: warning: $SAFE=3 does no sandboxing; you might want to use $SAFE=4
3
ruby 1.9.1p0 (2009-01-30 revision 21907) [i686-linux]
true
-e:1:in `

’: Insecure: can’t define method (SecurityError)

2009-03-30
451ERROR

I misinterpreted the stack trace in the above Erratum; Even at level 4 a tainted proc can be passed to a method.
ruby -ve ‘def a; yield end;p method(:a).taint; x=lambda{ $SAFE }.taint;p x.tainted?; $SAFE=4; a(&x)’
ruby 1.9.1p0 (2009-01-30 revision 21907) [i686-linux]
#<Method: Object#a>
true

2009-03-30
496TYPO

This section feels unfinished.
1) Many interface return → end or → enc instead of → encoding
2) Many examples are missing (or misleading, like default_internal=)

2009-03-30
23TYPO

double period…
“Chad Fowler and Andy Hunt..”

2009-03-30
43ERROR

command “ri GC” now has additional method (malloc_allocated_size, malloc_allocations) and returns…

——————————————————————————————— Class: GC
The GC module provides an interface to Ruby’s mark and sweep
garbage collection mechanism. Some of the underlying methods are
also available via the ObjectSpace module.


Class methods:
———————

count, disable, enable, malloc_allocated_size, malloc_allocations,
start, stress, stress=

Instance methods:
————————-

garbage_collect

2009-03-30
44ERROR

results for typing ri assoc now returns four results and is now …

more than one method matched your request. You can refine your
search by asking for information on one of:

Array#assoc [Ruby 1.9.1]
Array#rassoc [Ruby 1.9.1]
Hash#assoc [Ruby 1.9.1]
Hash#rassoc [Ruby 1.9.1]

2009-03-30
47SUGGEST

the use of number as the name of your number variable at first makes the example look like number is a special object to call when you want to test the length of a number. Whereas, mynumber or any specific naming more clearly shows that it is just the creation of any object with a numeric value.

See below….
——————————————————————————
number = Math.abs(number) // Java code
In Ruby, the ability to determine an absolute value is built into numbers—they take care of
the details internally. You simply send the message abs to a number object and let it do the
work.
number = –1234 # => –1234
positive = number.abs # => 1234

2009-03-30
92TYPO

But what it you wanted to iterate and receive an index, but use a different method than each
to control that iteration?

should read

But what IF…

2009-03-30
735ERROR

On page 735, the footnote says that leap seconds are used because “years are not really a convenient number of hours long”. But aren’t leap seconds used because days are not a constant number of seconds (because the earth’s rotation is not constant), and leap days used to handle the fact that years doesn’t have an integer number of days?

This erratum also happens in the first and second edition.

2009-03-30
555OK

Hash::index is deprecated. This should show in the doc (and not in the example).

2009-04-08I believe it does say so.
16TYPO

in the first line: it should be “previous two editions” missing s on edition

2009-04-13
489ERROR

Enumerable::each_with_object takes an optional block, which should be specified in the interface line

2009-04-13
488TYPO

In “enum.each_cons( length ) [ {| array | block } ]”, why the []? If it’s because the block is optional, then the [] are missing in most methods of enumerator. Otherwise they should go (same with each_slice)

2009-04-13
289DEFER

Dear Dave, Thanks for the great book. If still possible I do want to make one suggestion for the chapter IRB. One very handy feature of the IRB is the use of _ which refers to the last result. So:
>> 3+2
=> 5
>> _ + 5
=> 10

2009-04-13Indeed that's a useful feature. I can't see a way to add it without repaginating the book, which I can't do without breaking a lot of stuff, but I'll keep it on the list.
533ERROR

Quoting the book: “The order in which keys and/or values are returned by the various iterators over hash contents may seem arbitrary and will generally not be in insertion order.”

This is no longer true for Ruby 1.9. Order is maintained.

Thanks for the great book. Looking forward to my paper copy.

2009-04-13
339TYPO

“the variable d is not shared before it occurs only inside the block” should be “the variable d is not shared because it occurs only inside the block”.

2009-04-13
122SUGGEST

End of first para:
“Given a MatchData object, you can call pre_match to
return the part of the string before the match, post_match for the string after the match, and
index using [0] to get the matched portion.”

Funny I never used [0] for that purpose before, always #to_s.
Maybe this approach is worth being mentioned too? YAF?

2009-04-08
69TYPO

In Figure 4.1, the picture for a[1…3] is missing the right-side border of the box around “cat”

2009-04-13
28TYPO

The link in the last paragraph of the “Windows Distributions” extends past the right margin and even the right edge of the page (although it does go to the rubyinstaller page on RubyForge).

2009-04-13This is an (unfortunate) side effect of hyperlinking in the PDF: on this particular book we can't hyphenate and split a hyperlink. Sorry...
493ERROR

Enumerable::reverse_each should have the “1.9” symbol since it is new.
Array::reverse_each is incorrectly described: the block is now optional. It probably shouldn’t be there since it inherits the reverse_each from Enumerable.

2009-04-13I've left it there because it was in 1.8
496TYPO

Beginning of Enumerator::new states “The second form constructs…”. Should read “The first form constructs…”

2009-04-13
496OK

“with the method Kernel#to_enum (or via its alias, Kernel#enum_for).”.gsub(“Kernel”,“Object”)

2009-04-13enum_for is ctually defined in the Kernel module
540TYPO

Interface of Hash#rassoc missing the closing parenthesis.

2010-09-05
537OK

Hash#delete_if: interface probably shouldn’t have the ⟨ ⟩ around the block. Same with Hash#reject!

2010-09-05They return an enumerator if no block is given
754TYPO

First line of text: “generator-lke” should be “generator-like”

2010-09-19
681TYPO

Interface of String#gsub has second and third form on the same line

2010-09-05
TOCTYPO

The page numbers in the Table of contents, index, etc. are 1 too small

2009-04-26
559TYPO

For “readbyte”, it says “Returns the next 8-byte byte”. I suspect this should be “8-bit byte”.

2010-09-05
688TYPO

The first line of the description of slice! starts “Deletes the specified portion from strand…..”

There is a space missing between “str” and “and”.

2010-09-05
568TYPO

This line looks a bit sketchy:
Available only with the
-n or -p command-line options are present.

2010-09-05It should say "only *if*", not "only *with*")
542TYPO

The specification of the method “to_hash” says "see page 375. I think this should be page 378.

2010-09-05
688OK

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".

2009-04-26The previous line removes the 'i', so all the characters have shifted down.
AllTYPO

The page numbers in cross references are 1 below what they should be.

2009-04-26
622TYPO

obj =~ other_obj
→ !(obj=~ other_obj)

should be

obj !~ other_obj
→ !(obj=~ other_obj)

2010-09-05
488ERROR

Enumerable#detect should have a “1.9” symbol next to it, since it can now be called without a block

2010-09-05
452SUGGEST

In Array#cycle, the following should be removed:
“Equivalent to enum.to_a.cycle. See Array#cycle”
since… we are at Array#cycle!

2010-09-05
455TYPO

Interface of Array#frozen: “frozen?!”.gsub(“!”,“”)

2010-09-05
535TYPO

Missing “)” in interface after “hsh.assoc( key”

2010-09-05
270OK

Apparently, there was a mixup between ∂ (U+2202) and δ (U+3B4). All examples are given with δ but the codepoints are those of ∂. Thus there are many errors in the book, in this section and in the String reference section.

2009-04-26It's just the way TeX prints the character.
695ERROR

String#upto has a second optional argument.

2010-09-05I also now document the special behavior when the strings contain digits
496ERROR

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.

2010-09-05
584TYPO

The bottom of the page describing Marshal is cut off.

2010-09-05
631TYPO

Missing closing parenthesis after + in Object#to_enum interface

2010-09-05
621ERROR

In Ruby 1.9, retuns an enumerator if no block is given.

2010-09-05
591OK

Method#arity refers to Method#parameters. AFAIK, such a method does not exist (yet).

2010-09-05Ah, but now it does and it'll be documented in the next printing... :)
621ERROR

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” symbol should be added.

2010-09-05
807TYPO

“It’s” should not have an apostrophe in “the module uses it’s random_bytes method”

2010-09-19
489ERROR

Enumerable#find_index can also be given a single argument (as shown in Array#find_index)

2010-09-05
454ERROR

Array#find_index returns an enumerator if no block and no argument is given

2010-09-05
131TYPO

“subsubtring” where “substring” should be used: “You’ll sometimes want to match a pattern only if the matched subsubtring is preceded by or followed by some other pattern.”

2010-09-02
133TYPO

Either the word “refer” or the word “count” should be removed from this sentence: “Negative backreference numbers refer count backward from the place they’re used, so they are relative, not absolute numbers.” I think “refer” should go.

2010-09-02
498ERROR

Enumerator#next is 1.9 only, so there should be a “1.9” symbol next to it.

2010-09-05
699ERROR

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 →array
Returns an array of strings (s/b symbols) representing the names of the instance variables.
Customer = Struct.new(:name, :address, :zip)
joe = Customer.new(“Joe Smith”, “123 Maple, Anytown NC”, 12345)
joe.members # => [:name, :address, :zip]

2010-09-05
574TYPO

#39013: The bottom of the page describing Marshal is cut off.—Dave Thomas

1, Erratum noted above references page 584, should be 574
(at least it is in my paper copy :-) )

2. What, if any, information is missing ?
(my page ends with : newt.other_data # => “wibble”
along the very bottom edge of the page…)
(the next page starts with the Module constants section)

2010-09-05
493TYPO

“that is, any? will return true…” should read “that is, one? will return true…”

2010-09-05
337ERROR

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 I typed in from the text:

##### begin classvars.rb
class Holder
@var = 99 def Holder.var=(val) var = val end def var @var
end
end

@@var = “top level variable”

a = Holder.new
puts “a.var: #{a.var}”
Holder.var = 123
puts “a.var: #{a.var}”

def a.get_var
@@var
end

puts “a.get_var: #{a.get_var}”
puts “@var: #{@var}”

##### end classvars.rb

(Essentially, this is the code from the text using puts to produce output. Also, at the end, I show the value of the top level variable @@var.)

Here is the Ruby version and the output I see:

$ ruby -v
ruby 1.9.1p0 (2009-01-30 revision 21907) [i686-linux]
$ ruby classvars.rb
a.var: top level variable
a.var: 123
a.get_var: 123
@@var: 123

2010-09-05
337OK

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 version, the output agrees with the text:

$ ruby1.9 classvars.rb
a.var: 99
a.var: 123
a.get_var: top level variable
@@var: top level variable

Perhaps this is a Ruby bug in 1.9.1p0 instead of a book erratum?

2010-09-05In Ruby 1.9.2 it changes again. THe whole situation with class variables makes me despair.
533ERROR

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 convertible to a hash.

See redmine #1385, confirmed ruby-core #23433

2010-09-05
57OK

Assignment method is:

def price_in_cents=(cents)
@price = cents / 100
end

Shouldn’t the middle line be:
@price = Float(cents) / 100 ?

Puts on my system give 12 and 1200 without the Float(…)

Am I missing something here? Thanks.

2010-01-16It is divided by 100.0, so the operation is performed in floating point automatically.
56OK

Some text was cut away, last text was: " have an exact internal representation. When we "

2010-01-16the footnote continues on the next page…
341ERROR

Description of $stdout states: “Assignment to $stdout is not permitted: use $stdout.reopen instead.”

I believe this is not exact. STDOUT can’t be reassigned (obviously since it is a constant), but $stdout is a variable and has STDOUT as default value, but can be reassigned. See The Ruby Programming Language, for intance to section 9.7.1.4, or search ruby’s source code for “$stdout = ”

2010-09-05Yup: that was a cut and paste error... :(
487SUGGEST

The first section of the Enumerator description says:
“Some of the methods in the Enumerable module can return an Enumerator object”

But the example you give actually returns an Array…?

When I look at the method used (take_while) you would only get an Enumerator object if no block is given. But you give a block.

2010-09-05
339ERROR

The second paragraph for section “break, redo, next, and retry” says: “retry restarts the loop, reevaluating the condition.” However on page 147 there’s a footnote saying “Prior versions of Ruby also supported the retry keyword as a looping mechanism. This has been removed in Ruby 1.9.”

2010-09-05
337SUGGEST

The description for first form of ‘case’ expressions says: “case when condition …” while the description for “if” and other similar expressions says: “if boolean-expression …”. So this implies there’s a difference between a ‘condition’ in a “when” clause and a ‘boolean-expression’ in “if”. However the book doesn’t say anything about what the difference might be.

2010-09-05
349SUGGEST

First paragraph says: “… A module may contain class and instance methods and may define constants and class variables. As with classes, module methods are invoked using the Module object as the receiver…”. The term of ‘module methods’ is not defined anywhere. Presumably they are class methods defined in a module.

2010-09-05
353OK

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 examples is given for the third form. I doubt it’s really identical to the others. Usually when calling a [] method you need to put something between the brackets.

2010-01-16Works fine
353ERROR

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(…).” Who’s ‘a’ and where do ‘name’ and ‘args’ go? Maybe it wants to say “name.call(args…)”?

2010-09-05
355TYPO

Second line in first paragraph has “exceptioons”.

2010-08-31
396TYPO

Last paragraph says: “Previously, constants were looked up in the lexical scope in which there were referenced.” It should be “…they were referenced.”

2010-09-05
399TYPO

First paragraph ends with “Because of this, most people are moving away from this style of CFinstance_evaled block.” Not clear what ‘CF’ stands for. Maybe a font marker?

2010-09-05It was some layout that leaked through,
198TYPO

The second paragraph has ‘expectations’ misspelled twice: “expections” in the second line and “expecations” in the fourth line.

2010-09-05Both are fine words, though... :)
613TYPO

The header for class Object shows it has not superclass. However in Ruby 1.9 it has BasicObject as superclass.

2010-09-05
271ERROR

The paragraph under ‘Interactive Configuration’ says: “For example to change your prompt back to DEFAULT you could use the following:” but then the code is ‘conf.prompt_mode = :SIMPLE’.

2010-09-05
438TYPO

Second paragraph, third line: “tha” should be “the” (“the safe level of the code that invoked tha [sic] proc”).

2010-09-05
81SUGGEST

Technically, one might say that a :fox is “vulpine”. One would use “lupine” for a :wolf, maybe. :-)

2010-08-31
402OK

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 “undefined method ‘[]’ for :called_name:Symbol”

2010-01-16Works here
607TYPO

In the “1.9” note for define_method, “This methods” should read “These methods”.

2010-09-05
235TYPO

The -W description has “level or two”. should be “level of two”

2010-09-05
186TYPO

In ‘unittesting_3.rb’:
class TestRoman < MiniTest::Unit::TestCase

of course it is Test::Unit::TestCase and it is correct in the subsequent examples.

2010-09-05Actually, both work fine, and I wanted to demonstrate that, but I think in retrospect it is too confusing, so I'll go back to Test::Unit
255OK

I read: “String literals are always encoded using the encoding of the source file that contains them, regardless of the content of the string”.

But, actually, I’m trying it and it doesn’t behave like that.

  1. coding: utf-8
    puts ENCODING
    puts “ciao”.encoding.name
    puts “ciao \\u03c0”.encoding.name

Executing, it produces:
UTF-8
US-ASCII
UTF-8

So, that phrase and the following example aren’t correct.

If it is relevant, this is my ruby version:
roby@debian-roby:~$ ruby -v
ruby 1.9.0 (2008-06-20 revision 17482) [i486-linux]

2010-09-05I believe the book is correct. There was a time when strings containing only 7-bit ascii were encoded as ascii, but now they all take on the encoding \n \n \ndave[ruby3a/Book 8:53:07] cat t.rb \n# coding: utf-8 \nputs __ENCODING__ \nputs "ciao".encoding.name \nputs "ciao \\u03c0".encoding.name \ndave[ruby3a/Book 8:53:11] ruby -v t.rb \nruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.4.0] \nUTF-8 \nUTF-8 \nUTF-8 \n \n \n
243TYPO

I believe that packaging_14.rb should be placed in “lib/anagram/runner.rb” not in “lib/runner.rb”

2010-09-05
879TYPO

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 all of the socket pages (879-892 in the PDF).

2010-10-14
316SUGGEST

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 reader to go to the “unstable” subdirectory (ftp> cd pub/ruby/binaries/mswin32/unstable) to download Ruby. I may not really understand the “stable” vs “unstable” of the Ruby community, but the Ruby website download page lists “Stable version”, “Stable Snapshot” and “Nightly Snapshot” and recommends using the “Stable Version”. So shouldn’t the book be recommending that as well?

2010-09-19
676TYPO

The return value of the method String#partition is printed as “[ before, match after ]”. Shouldn’t it be “[ before, match, after ]”?

This typo also appears on page 677 in the method String#rpartition.

2010-09-05
677TYPO

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.rstrip! —>
… self or nil

While (I think) it should be like this:
… str.rstrip! —> self or nil

2010-09-05
830TYPO

In the table “C Data Types to Ruby Objects” LONG2NUM is lacking the end parenthesis.

2010-09-19
556TYPO

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.

2010-09-05
328328TYPO

In the 1.9 specific Section ‘Rational and Complex Numbers’:

“There are for rational or complex literals, for example.”

2010-09-05
351ERROR

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 valid for loop control in 1.9 (although this fact is mentioned earlier in the exception handling topic as a footnote)

2010-09-05
623TYPO

In the synopsis of define_singleton_method, the second line reads “obj.define_method(symbol) { block } -> proc”. I believe “define_method” should be “define_singleton_method”.

2010-09-05
118SUGGEST

A sentence near the bottom says:

“nil is equivalent to false in Ruby”

but the Ruby interpreter disagrees:

irb(main):110:0> nil false => false irb(main):111:0> nil = false
=> false

2010-09-02Nil is equivalent to false in a boolean context. I'll add the extra words in the next printing.
allSUGGEST

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 chapter number as well as chapter name. (My professor assigns readings by chapter number.)

2010-01-16
707TYPO

Thread#[]
The current example is not informative; the “produces” section shows what happens if the new threads have not had the time to execute anything. The official rdoc output gives the right information:

produces:
#: C
#: B
#: A
#:

2010-09-05
365SUGGEST

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…

2010-09-05If you remove the 'next', then there won't we a return value of 99. \n \nHowever, I'm changing the example to \n \n \n\t def ten_times \n\t 10.times do |i| \n\t if yield(i) \n\t puts "Caller likes #{i}" \n\t end \n\t end \n\t end \n \n\t ten_times do |number| \n\t next(true) if number ==7 \n end \n
379ERROR

names = %{ant bee cat}

results in the string “ant bee cat”. What you want instead is

names = %w{ant bee cat}

which results in [“ant”, “bee”, “cat”}

Without this fix, the following statement

result = names.map {|name| name.upcase}

makes no sense, since “.map” is something you do to an array (or other Enumerable), not to a String.

2010-09-05
621ERROR

Documentation for Numeric#remainder is not exact. x.remainder(y) = x - (x/y).truncate
See redmine #585

2010-09-05
351OK

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 as the value of the statement, and the value given to next is silently ignored. ”

This is not correct in the case of a for loop, as demonstrated by this code:

class Foo
def each
p yield
p yield
p yield
end
end

f = Foo.new
for i in f
next “next”
end

Running it produces this output:

“next”
“next”
“next”

which shows that the value given to “next” is not “silently ignored’, but rather is returned as the value of ”yield".

2010-09-05It does describe this case above, but I agree my wording is sloppy here. I'll tighten it up.
595ERROR

Module#<, <=, …

“all operators return false” should be
“all operators return nil”

2010-09-05
406ERROR

In section “instance_eval and class_eval”,

First paragraph says: “The methods Object#instance_eval, Object#class_eval, and Object#module_eval”

Those last two should actually be Module#class_eval and Module#module_eval

2010-09-05
606ERROR

The method parameter can be a Proc or Method object
=>
The method parameter can be a Proc, a Method or an UnboundMethod object

2010-09-05
623ERROR

The method parameter can be a Proc or Method object
=>
The method parameter can be a Proc, a Method or an UnboundMethod object

2010-09-05
119TYPO

In the section “Changing Strings with Patterns” shouldn’t the first sentence read: “The sub method takes…?”

2010-09-02
143ERROR

For the section Splat! Expanding Collections in Method Calls, the 1.9 marker is in front of the paragraph “When you call a method . . .”

This does work in 1.8.6,7, but the splat has to be at the end. In other words, a reader might be misled to think the the basic functionality is missing in earlier versions, while only 1.9 lets you have multiple splats in different orders.

2010-09-02What's different in 1.9 is that you can pass in an enumeration, too.
642ERROR

Proces.exec: signature is missing the optional env (see Kernel.exec)

2010-09-05
88OK

The line of sample code in tutcontainers_63.rb that reads:

proc3 = ->(arg1, arg2) { puts “In proc3 with #{arg1} and #{arg2}” }

…only seems to work if the left parenthese abuts the -> operator. Including a space, as with the previous assignments that don’t show parentheses, causes an error: “tutcontainers_63.rb:3: syntax error, unexpected tLPAREN_ARG, expecting keyword_do_LAMBDA or tLAMBEG”

2010-01-16Indeed. I find the whole syntax for this to be ugly.
789ERROR

“Because Ruby does not use operating system threads…” is not true for 1.9.

2010-09-19
139TYPO

In the last sentence of the second-to-the-last paragraph shouldn’t “argument” at the end of the sentence be pluralized?

2010-09-02
98OK

Last paragraph, line 4 says “A module can’t have instances,..”
Line 6 says “When this happens, all the module’s instance
methods are suddenly available as methods in the class as well.”

Should line 6 say “..all the module’s methods..”

2010-01-16Not really, because a module can also have module methods. \n \nIt'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.
141OK

When object writer is being initialized, the string my_order should be surrounded by double quotes. As written, ruby will look for a variable named my_order and throw an error because it doesn’t exist.

2010-01-16I'm just assuming you have an order lying around—it's not supposed to be anything special
708ERROR

Thread#group has not changed from Ruby 1.8 to 1.9, so there should be no “1.9” sign next to it.
Same goes for Thread#join, #keys and #raise.

2010-09-05
556TYPO

The result of the Rational method says ‘complex’, it should probably say ‘rational’.

2010-09-05
407396ERROR

“Previously it was impossible to pass a local or instance variable into a block…” shouldn’t say “local” since those are captured by the closure when using blocks. Since the _exec methods don’t allow for strings, this is always the case.

2010-09-05
426OK

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_method should be used to avoid the warning, though.

2010-09-05I don't see the problem with 1.9.2
366SUGGEST

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, and next you do not use them but it appears as if they would map correctly and be very useful.

Ultimately, it appears as if “lambda”s are just like methods: they return as a method and they check their arguments. “raw block”s however do neither.

In fact, this my be a “no no” but it appears as if “raw block” is a synonym for Proc.

I’ve always found all this really hard to remember and keep straight. But there appears to be much more consistency present than is presented in the text.

2010-09-05You're right: I was over-complicating that description. It'll be fixed in the next printing.
328SUGGEST

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 the two quote character pairs.

e.g.

puts %q(abc\\()
puts %q-x\\x

2010-09-05
449ERROR

Array#<=> can also return nil (when the argument is not comparable)

2010-09-05
466ERROR

Bignum#<=> can also return nil (when the argument is not comparable), same for all classes

2010-09-05
590ERROR

Math.log takes a second optional argument (base).

2010-09-05
406TYPO

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.
Therefore, any methods you define will become class methods.”

I had just read examples like “cat”.instance_eval(…), so I immediately thought, “Hey, wait a minute,
I thought I had just understood something else!” But then I realized what you were saying, and I
think it might have been clearer to me from the outset had you said,

“In contrast, instance_eval INVOKED ON A CLASS acts as if …”

2010-09-05
625ERROR

Object#id_ is not new in Ruby 1.9, so there should be not “1.9” icon next to it.

2010-09-05
487SUGGEST

Shouldn’t the first sentence of the description for the any? method indicate that collection elements are only passed until the given block returns true?

2010-09-05
541ERROR

Hash#select returns a hash (correct in doc, incorrect in interface line)

2010-09-05
841ERROR

‘rb_global_variable’ takes a pointer as its argument.

This section…
static VALUE obj;
// …
obj = rb_ary_new();
rb_global_variable(obj);

…should be replaced with something along the lines of:
static VALUE obj;
rb_global_variable(&obj);
// …
obj = rb_ary_new();

2010-09-19
681ERROR

String#gsub! can also return an enumerator, so the interface should show it (like String#gsub)

2010-09-05
57OK

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 paragraph of the page 51 is correct. Would you please clarify?

2010-01-16It uses the accessor method price.
544TYPO

decription of odd? is:

Returns true is int is odd.

should be:

Returns true if int is odd.

2010-09-05
483TYPO

s/UTF-*/UTF-8/

(you forgot to release the shift key :-)

2010-09-05
306TYPO

Under section “Getting and Setting properties”, the sentence “excel2.rb ( found in the ext/win32/samples directory)” should be “ext/win32ole/sample directory”, based on source code version of ruby-1.9.1-p376.
the author should specify this folder is in the ruby source code folder, or the beginner will find it is really hard to find this folder:

(1) I installed Ruby1.9 windows using one-click installer, version: ruby 1.9.1p243, but I did not find the samples folder.

(2) then I downloaded the ruby-1.9.1-p376-i386-mswin32.zip from ruby ftp server, unzip it, I found sample folder, it is under doc\\ruby\\ruby-1.9.1\\sample\\win32ole

(3), At last, I downloaded the ruby source code zip file, finally I found the sample folder is under ext/win32ole/sample

2010-09-20In the new printing, this code will be included in the download
306ERROR

The source code of modified excel2.rb is not working, it throws exception:
excel2.rb:7:in `[]=‘: (in OLE method `visible’: ) (WIN32OLERuntimeError)
OLE error code:0 in

HRESULT error code:0x8002000e
Invalid number of parameters.
from excel2.rb:7:in `

I found excel[‘Visible’] = true should be
excel.visible = true

I also found excelchart[‘rotation’]= rot is not working,
it should be excelchar.rotation = rot, so I think the earlier code snippet is also wrong:

excelchart[‘Rotation’] = 45

which means we can not use Ruby hash notation to set the properties.

Following are the correct code:

require ‘win32ole’

  1. –4100 is the value for the Excel constant xl3DColumn
    ChartTypeVal = –4100

excel = WIN32OLE.new(“excel.application”)

#excel[‘visible’] = TRUE
excel.visible = true
excel.Workbooks.Add()
excel.Range(“a1”).value = 3
excel.Range(“a2”).value = 2
excel.Range(“a3”).value = 1
excel.Range(“a1:a3”).Select()
excelchart = excel.Charts.Add()
excelchart.type= ChartTypeVal

30.step(180,5) do |rot|
excelchart.rotation = rot
#excelchart[‘Rotation’] = rot
sleep(0.1)
end

excel.ActiveWorkbook.Close(0)
excel.Quit()

2010-09-20Indeed, this seems to have changed. In the new printing I'll change this example to use OpenOffice, and to use the a.b notation
307TYPO

The IE navigate ruby code win32_11.rb is not working, it throws the following exception:

win32_11.rb:40:in `message_loop’: method `backtrace’ called on terminated object
(0xc4b900) (NotImplementedError)
from win32_11.rb:40:in `block (2 levels) in


from win32_11.rb:39:in `loop’
from win32_11.rb:39:in `block in


from win32_11.rb:38:in `catch’
from win32_11.rb:38:in `

But I found ienavi.rb under ext\\win32ole\\sample ( source code version is ruby-1.9.1-p376) is working,
the only difference is ienavi.rb does not use throw/catch statement, it use a flag and while while loop.

2010-09-20Indeed: it looks like the 1.9 throw/catch implementation breaks win32ole. I'm changing the example in the next printing.
309TYPO

ext\\win32ole\\samples directory should be ext\\win32ole\\sample directory

2010-09-20
310ERROR

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) (ArgumentError)
from win32_15.rb:15:in `

2010-10-14It's changed in 1.9.2. Try the following: \n \n

\nrequire 'dl/import'
\n
\nmodule User32
\n  extend DL::Importer
\n  dlload 'user32.dll'
\n
\n  extern "int MessageBoxA(long, const char *, const char *, int)"
\nend
\n
\nMB_OKCANCEL = 1
\n
\nUser32.MessageBoxA(0, "OK?", "Please Confirm", MB_OKCANCEL)
\n
\n \n
457ERROR

Array#permutation’s interface and doc should reflect the fact that the size argument is optional.

2010-09-05
448SUGGEST

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 into think that the method is available to any Enumerable (which is often but not always the case)

2010-08-31
503TYPO

in File.new, it says

See also IO.open on page 505

but IO.open is on page 540

2010-09-05
131ERROR

Thanks for an awesome book!!

It seems that the Oniguruma library was added in 1.9, so there should be a “1.9” notation in the margin like the other 1.9-specific features.

2010-09-02
809TYPO

s/CArray/Array/
(and reconstitute the proper formatting)

2010-09-19
392TYPO

figure 24.4: I mean the superclass of Class is Module

2010-09-05
466SUGGEST

In the survey of the instance methods of the Complex class, the description of magnitude() seems to be the same as that of abs(). Could you please explain the difference? (Or if there isn’t one, explicitly state that they are synonyms.)

2010-09-05
921TYPO

The index includes an entry for relection, between reject! and remainder.

2010-10-14
13OK

Second paragraph, final sentence reads:
“After all, most everything in Ruby is an object …”
Should be:
“After all, almost everything in Ruby is an object …”

2010-08-31I kinda like it as it is: it's idiomatic (I exercise most every day... etc)
684OK

lstrip second example is correct?
“\\000…” becomes “\\x00…”

2010-09-05Yes, it's correct. \\x00 is the same character as \\000. lstrip does not strip nulls, unlike rstrip.
55TYPO

in the example
b.setPrice(calculate_discount(b.getPrice());
should read
b.setPrice(calculate_discount(b.getPrice()));

2010-08-31
630TYPO

Misspelling of “arguments” in the form of “arguements” in the paragraph describing “curry”. There are two instances of the misspelling.

ex. “…a proc that will take from zero to n arguements…”
“…prebaked in and that takes m-n arguements…”

2010-08-31
746ERROR

In the two Ruby examples of DL, the outout lines appear in the opposite order to expected. Either this is an erratum, or there should be some text explaining why it happens (presumably buffering).

2010-09-19Yup—that's caused by the C-runtime buffer its output and the RUby runtime buffering its. THe next printing fixes this by adding an fflush call to the C
760TYPO

The second sentence of the description of GServer sounds wrong. It should be written as a list of things for the class user to do. E.g. “To use it, subclass the GServer class, set the port (and potentially other parameters) in the constructor, and then implement a serve method to
handle incoming requests.”

2010-09-19
325OK

The =begin comment construct needs to be added.

My basic complaint about this book (one of few) is that I can’t use it as a reference effectively. Yes, the “=begin” is mentioned but its under chapter 19. My silly pdf reader (Preview on the Mac) can not search for =begin correctly. Acrobat reader found it but only because I sorta mostly thought it was “=begin” but wanted to make sure. I tried searching for comment but didn’t see it because it was in the wrong place.

The reference part of the book (which I assume is section III), needs to be totally complete. Even if it repeats some things.

2010-09-05It's there in the next paragraph: "Physical lines between a line starting with =begin and a line starting with =end are ignored \nby Ruby and may be used to comment out sections of code or to embed documentation."
317SUGGEST

Assoc and FType in Running Ruby Under Windows is not all of it. I guess it is also necessary to reference

1. PATHEXT setting, even though it is explained in the FType help.

2. Explorer Open for .rb/.rbw files, since on Windows assoc/ftype may differ from what happens when I double click a file in Explorer or other file manager.

3. The registry keys that are involved in both 1 and 2 since on Windows file associations tend to be broken and require manual fixing. I understand that is not ruby specific, but is so wide spread that it is worth re-iterating.

2010-09-19
622613TYPO

A tiny typo in the heading row of instance method ‘!~’.

obj =~ other_obj → !(obj=~ other_obj)
should be
obj !~ other_obj → !(obj=~ other_obj)

2010-09-05
480TYPO

c* will match all files beginning with c, ‘c will match all files ending with c,

SHOULD BE “c, *c will match all files ending with c,” yes?

2010-09-05
28TYPO

Weblink (rubyforge.org/projects/rubyinstaller) in paragraph «Windows distribution» ending out of the page.

2010-08-31
74TYPO

six assertions… 5 assertions

“The results show that four test methods ran, successfully executing six assertions”

5 tests, 5 assertions, 0 failures, 0 errors, 0 skips

2010-09-02
128SUGGEST

Named regular expression matches need to be labeled as a ruby 1.9 feature.

2010-09-02
192177OK

Do the examples of Mutex need: require ‘thread’?
(ruby 1.8.7. patchlevel 249)

2010-09-05This book is for Ruby 1.9, and in that version of Ruby Mutex is built in \n
757OK

I am not sure about the line:
def_delegators(:@hash, :size, :has_key?)

st.has_key?(‘cow’) # => true

How is the delegation working here?
It seems this is invoking the regular Hash#has_key? method.

Is the point to show that def_delegators(:@hash, :size, :has_key?) has no effect?

Please let me know

Ali Rizvi
aliabbasrizvi@gmail.com

2010-09-19THe example shows that when has_key? is called on the SymbolTable object, it is passed on to the @hash instance variable—the call gets forwarded.
144OK

In the following section, the output shown is for a plus table but in the paragraph above this code, the student was selecting a times table. The input request shows a t as well indicating times. The output should be:

1, 2, 4, 8, 16, 32, 64, 128, 256, 512

(t)imes or (p)lus: t
number: 2
2, 4, 6, 8, 10, 12, 14, 16, 18, 20
2010-09-02The output is a two-times table: 2x1 = 2, 2x2 = 4, etc.
540SUGGEST

Interface and description of Hash#rassoc should use ‘val’ as the input parameter instead of ‘key’ as it is the value in the hash that is being tested. So, this just reads wrong: “… first element whose value is key, returning the key and value….” This change also makes the interface clearer: hsh.rassoc(val) -> [key,val] or nil.

2010-09-05
272OK

The book says: “, and output will be transcoded from internal to external encoding
on write operations.”

Is that really correct? I think that on write operations what really matters is the encoding of the string being sent to output, not the internal encoding of the IO object, which is only used on read operations to transcode from external to internal encoding.

2010-09-05Transcoding also takes place on write operations, converting from the internal encoding to the external encoding.
578ERROR

MatchData#values_at documents that it is a “Synonym for MatchData#select.”, but there is no documentation for MatchData#select. (MatchData#[] references both names on p.576)

2010-09-05
7SUGGEST

I was a bit confused when I used macports and had all executables installed with the 1.9 suffix. (Even though you mentioned this in the book.) One suggestion is to tell readers about the “+nosuffix” option in macports. Also, when readers use IRB the first time a few pages later, it could be useful to remind them they need to type the 1.9 suffix if necessary.

2010-09-19
194SUGGEST

Regarding the code for ts_dbaccess.rb, since it appears right after the discussion about putting tests in the test/ directory and running it like this “ruby -I . test/test_roman.rb”, it may be clearer if your ‘require’ statements for ts_dbaccess.rb follow the same convention:

require ‘test/test_connect’
require ‘test/test_query’
require ‘test/test_update’
require ‘test/test_delete’

That lets you follow the convention previously described. Otherwise, ts_dbaccess.rb won’t know where to find the required files (other than ‘test/unit’ of course).

2010-09-05Good catch. In fact, they should probably just use require_relative.
343343TYPO

RUBY_REVISION is missing the “1.9” only tag

2010-10-14
114OK

??? example ==> 0…“cat”.length

2010-10-14Thats a range from 0 up to the length of the string "cat"
9ERROR

Table of contents for Built-in Classes and Modules and Standard Library aren’t generated correctly

2010-11-21This reference to the PDF bookmarks, which appeared in the sidebar in some PDF readers in the prior version. The were dropped in the transition to the new, but it wasn't deliberate. I'm working to get them back.
276TYPO

Footnote URL yardoc dot ORF [sic] should be dot ORG

2010-11-22
276SUGGEST

“Some context is handy”, but the Existing Errata listed by your tool does not apply to the version I am looking at.

2010-11-14There's not much I can do here: the new printing is a totally retyped book, using a totally different build system. The pagination isn't the same. However, all old errata were fixed in this new printing.
203TYPO

In the last textual paragraph: “The let method creates what looks like a variable (it’s actually a dynamically defined >>>mathod<<<)”

2010-11-22
13OK

The link in page 13 is wrong

2010-11-22I don't see a link on page 13: could this be the previous edition?
69TYPO

Page 69 ends with example unit test output reading “4 tests, 6 assertions, 0 failures, 0 errors, 0 skips”. The second to last sentence of the page describes this output, saying “five test methods ran, successfully executing five assertions.”

The code on the following page does include 5 test methods with 5 assertions, but the sentence in question is not describing that code.

2010-11-22You're right: that text was describing the next test run. It should say "The results show that four test methods ran, successfully executing six assertions."
29OK

I’ve only installed RVM and not the ruby package on Ubuntu. The shebang notation is just totally wrong for me in this instance. /usr/bin/ruby doesn’t exist, but /home/dsouth/.rvm/rubies/ruby-1.9.2-p0/bin/ruby does (and yet that is horribly ugly).

Probably something more for RVM than the book, but if I write my code for my RVM environment, then it is only going to work with MY environment. If I install and write my code for the system ruby, then I may not be running the ruby version that I would expect to be running in RVM?!?

Oh the horror! :)

2010-11-21You use shebang when you explicitly want to add the path to an interpreter (ugly or not). If you don't then I woulnd't use it (I very rarely do).
266OK

In Figure 18.1 (despite several corrections since the version of 2010-11-09) there are some em-dashes that should be double hyphens: —version and —noinspect in the Option column, and —noreadline in the Description column.

Kaizen.

2010-11-22I don't see them here: here's the page I see: \n \nhttps://skitch.com/pragdave/rbq88/ruby3-p-00.pdf-page-266-of-916 \n \n
266ERROR

“-I path . . . Specifies the $LOAD_PATH directory.” is the text produced by “irb -h” itself, but it would be better to write “-I directories . . . Same as Ruby’s -I option” since the value of $LOAD_PATH is not replaced, and more than one path can be given and prepended to $LOAD_PATH.

2010-11-22Great recommendation.
309TYPO

“Following the type character is a delimiter, which can be any nonalphabetic[!] …” should be “nonalphanumeric” (confirmed with irb and a look at parse.y). Footnote: the underscore is a word character, but not an alphanumeric character.

2010-11-22
312SUGGEST

Figure 22.2 You might want to add a tedious footnote about \\o and \\oo, and about \\xh. “\\08” => “\\x008”. “\\xA_1” => “\
_1”. Or perhaps simply say "Once you understand Ruby regular expressions, the truth is that /\\\\[0-7]{1,3}/ is the syntax for octal character constants, and /\\\\x\\h{1,2}/ is the syntax for hex character constants.

2010-11-22
316ERROR

"\\0, \\1, \\2, … \
, \\&, \\‘, \\’, \\" It is misleading to include \\0, \\&, \\`, \\’, and \\ in the discussion of regular expressions, since they are only useful in the interpretation of substitution strings (whereas \\1 .. \
do have a role in regexps). Note: \\0 is a synonym for \\& in the interpretation of a string by Regexp#sub/gsub and nowhere else. E.g.,

“x&x”.gsub(/\\&/, “AMP”) => “xAMPx”

2010-11-22
318SUGGEST

Figure 22.3 You might want to add ENCODING to your list of reserved words

2010-11-22
35OK

Because writing accessor methods…

should be

Because reading accessor methods…

the above occurs in the third para on the page.

2010-11-22I think it's correct as it stands: the meaning is "because it is so common to have to write accessor methods, Ruby provides you with a shortcut"
392TYPO

In Figure 24.6, section: “Class and module-related hooks” comma-space is missing between the initialize hook names

2010-11-22
186TYPO

One of the Object is superfluous in “[…] you can set up a signal handler using Object#Object.trap” (bottom of p.186)

2010-11-22
348SUGGEST

The “Block Arguments” section does not mention (remind) “that you can now define block-local variables by putting them after a semicolon in the 1.9 block’s parameter list” nor that “parameters to a block are now always local to a block” (excerpts from p.72)
If a reader already comfortable with ruby 1.8 skiped the 4th chapter, she will miss those 2 subtleties.

2010-11-22
67ERROR

The example hash excerpt with “the” mapping to its count is wrong the second time it is shown. Is:

{ …, “the” => 1, … }

should be:

{ …, “the” => 2, … } ???

2010-11-22Good catch
335TYPO

“while boolean-expressiondo” is missing a space

2010-11-22
413TYPO

“Marshal.load” would make more sence in this sentence: “When the object is subsequently reconstituted using Marshal.dump, the method marshal_load […]”

2010-11-22
6TYPO

The link to skip to “Source Code From This book” says it’s to section 1.2, but it’s actually to a subsection within 1.2. It would be less confusing to remove the 1.2.

2011-04-12
107ERROR

5th para, starting “Once you have …”
Here using both irb1.9 and Ruby 1.9.2p0 you can freely mix named matches with the $ notation, eg “Hour is #{hour}:#{$2}{$3}” => Hour is 12:50am

2011-04-12
336TYPO

def defname <(<, arg <, = val >>* …
The comma before = val is wrong

2011-04-12
249TYPO

In show_encoding there is a puts on the first line and then a string on a line by itself. It looks like there is a missing + after “… size} bytes) ” or a missing puts on the next line.

The line “has encoding #{str.encoding.name}” doesn’t show up in the output.

2011-04-12
41OK

The pallet example is an infinite loop

2011-01-25Actually, it never loops at all :)
330TYPO

Figure 22.4, the operator ^= (XOR=) is missing from the list of assignment operators

2011-04-12
330TYPO

var[“a”, /^cat/ = “three”} … in the “Element Reference” column of the unlabeled figure at the bottom of the page is syntactically wrong.

2011-04-12There's a missing '] before the = sign
150OK

Extra ’ in “artist = ”’Trane"

if artist "John Coltrane" artist = "'Trane" end unless use_nicknames “no”

2011-04-12It's an apostrophe...
208ERROR

Figures are broken on kindle edition:

Figure 13.1: Testing framework assertions
Figure 13.2: Additional Test::Unit assertions

Here you can see the screenshots:
habreffect.ru/files/9a2/2f2e6bcb3/screen_shot-3010.gif
habreffect.ru/files/a5b/4e20f780c/screen_shot-3011.gif

PS. Could you please show notice about erratum format, because it isn’t possible to post links to screenshot. I think my previous post missed

2011-04-13
245TYPO

10 lines from bottom of page.

“These go in lib/test_finder.rb” should read “These go in test/test_finder.rb” (test/ not lib/)

2011-04-12
14TYPO

Invalid reference to the online appendix. Instead of pragprog.com/ruby3 it should be pragprog.com/titles/ruby3

2011-03-15
250TYPO

at “Adding Even More Automation” section library name “Jeweler” not “Jewler”

2011-04-12
128TYPO

In the first sentence of the “Setting Options” section, the character “m” is missing before “(multiline)”.

As we saw at the start of this chapter, you can add one or more of the options i (case insensitive), m (multiline), and x (allow spaces)…

2011-04-12
680TYPO

Documentation of Rational#==: Replace “is” with “if”. Thanks for this great book! :-)

2011-04-12
276TYPO

The code snippet is mis-formatted starting at the apostrophe in Debrinski’s algorithm. At that point a runaway italic quotation? starts that swallows up the =end, etc.

2011-04-12
311TYPO

There should be a space between Fixnum and 1. It appears in both the paper copy (page 308 there) and the pdf (v. 3.0) that there is no space between Fixnum and 1.

2011-04-12
197SUGGEST

Figure 13.1 title is “Testing framework assertions”. This figure directly follows to alternate testing frameworks, so it’s a little confusing if you’ve jumped right to those pages. The following page “Figure 13.2: Additional Test::Unit assertions” conciseness is appreciated, and Figure 13.1 might benefit from the same.

2011-04-12
193SUGGEST

The Shoulda section in “13.4 RSpec and Shoulda” talks about nesting contexts and the code examples walk you through this. As nesting is not mentioned in the RSpec section, one might walk away with the misconception that that is a strength of Shoulda over RSpec.

2011-04-12I can see what you're saying, but I don't think the implication is there—I'm just trying to show some useful stuff, rather than do a step-by-step comparison.
27TYPO

The first sentence in the “Source Code from This Book” section has a missing “of”.

“We have made much the source code from this book available for download.”

should be:

“We have made much of the source code from this book available for download.”

2011-03-15
133TYPO

At the top of this page, there’s a missing closing parenthesis in the first paragraph.

Folks sometimes use a splat … (but that are perhaps … in a superclass. (Note that in this example … were given to the original method.”)

2011-04-12
68OK

The loop should be 0..4 instead of 0..5. Otherwise you get the following error:

ugly_word_count.rb:17:in `block in

‘: undefined method `[]’ for nil:NilClass (NoMethodError)
\tfrom ugly_word_count.rb:16:in `each’
\tfrom ugly_word_count.rb:16:in `

2011-01-30Note that there are three dots in the version in the book...
0SUGGEST

I have just noticed in the latest pdf the built-in classes and standard library are not expanded as bookmarks in the sidebar. Also they are not hyperlinked in the contents any more.

Needless to say this is a retrograde step in being able to get the documentation of a class quickely.

Also, but not important for pdf viewing the A, B, C, D, etc. marks in the right margin for the class reference are also missing.

Dave.

2011-04-12
645TYPO

Under spawn, in the second paragraph, second sentence the word ‘command’ is written as ‘commend’

2011-04-12
77OK

usage of ‘different than’ rather than ‘different from’ in the section Enumerators are Objects, paragraph 3 => line 1

2011-04-12
250TYPO

Although it started as a public Git repository, GitHib

maybe GitHub?

2011-04-12
845ERROR

The text at the bottom of page 184 hints that there is a description of condition variables on page 845. You can imagine my disappointment when I went there and found no mention of them! :-)

2011-04-12It should have referenced the Monitor library
799OK

The example on page 799 uses method MonitorMixin#new_cond, but that method is not described anywhere. Likewise, whatever class is returned by that method (presumably ConditionVariable) obviously has methods wait_while and signal, but they aren’t described either.

2011-04-12That's right—there are literally thousands of standard library methods—in this section I show a sample to give you an understanding of what a library does. ri and rdoc are your friends here.
67TYPO

Last code paragraph. { …,“the” => 1, … } “the” was just incremented, I think it should be { ‘the’ => 2 }

2011-04-12
319TYPO

print

2011-04-12
799ERROR

The second paragraph is very confusing and (I think) wrong. It says there are three ways of using Monitor: parent class, mixin, and object extension. It then says “we document the module form”, but “the module form” isn’t one of the three choices. It looks to me like it’s the object extension form that’s described. Then it says “the class form is effectively identical” - it that supposed to be “parent class form”? And what about the third form whichever that might be?

2011-04-12It should say "we document the mixin form"
81TYPO

The first line of vowel_finder_sum.rb (p 81) is missing in the book, but present in the referenced code from the Prag Prog site. Without it, the interpreter yells at me.

The missing line is

require_relative “vowel_finder” (I pencilled it into my book)

I’m still making my way through the book and am getting a lot out of it. Thanks guys! A perk of unemployment is learning a new skill!

Cheers!

Mike Manewitz
Austin, TX

2011-04-12
189OK

line 2, missing word(s). ‘check [to see if] the results are…’ or ‘check [that] the results are…’ Great book, really enjoying it! Will buy Rails 3.0.3 when it comes out.

2011-04-12I think the usage is probably OK as it stands
203ERROR

Not sure if my -v of Rspec is outdated, but it didn’t come with simplecov. I had to $gem install simplecov.

2011-04-12That simplecov code shouldn't have been there. Sorry
230TYPO

Installing Gems On… first command, $*name-matches build[er]

2011-04-12
BmarkTYPO

In the bookmarks of the PDF, Ruby Library Reference/Built-in Classes and Modules/Time takes you to Standard Library/Time on page 847 rather than the correct place on page 739.

2011-04-12
491OK

last line of 1st paragraph: “…languages call this operation foldl or reduce.”

2011-03-15If you're pointing out "foldl", that is the correct name.
203TYPO

Towards the end of the page, “(it’s actually a dynamically defined mathod)”, mathod should be method.

2011-04-12
65SUGGEST

“If used with a single integer index, the element at that position is replaced by whatever is on the right side of the assignment. Any gaps that result will be filled with nil:”

I had to reread the last sentence a couple of times. It could reference to gaps resulting either from “whatever is on the right side” or from using a new index. So I would rewrite it as “Any gaps that result from using indices not yet found in the array will be filled with nil:” or the like.

2011-01-25
68SUGGEST
  1. (this is ugly code — read on to see how we can improve it)
2011-04-12
93OK

First paragraph has this: “To reference the name sin unambiguously, our code can then qualify the name using the name of the module containing the implementation we want, followed by ::”

This is wrong, since “sin” is a method and so it is accessed using “.” and not “::” (as can be seen in the example below)

2011-01-25Actually, you can do both,,,
188SUGGEST

Fred Flintstone is a character from a show with (at least in the original series) not-so-modern stone age families where the men work, and the women are housewives.

I just watched Dave Thomas’ Ruby Conference 2010 talk. If you would like to encourage women to be programmers, should you be retiring the Flintstones to pre-history?

I also suspect that there’s more fictional male programmers than fictional female programmers in the PragProg series of books, but I haven’t checked. That’s accurately describing the status quo, but is it also endorsing it?

2011-01-25Actually, I consciously try to alternate hims and hers. I don't always do it right, but the intent is there. However, I also won't put in (say) "he or she"—the fact we're lacking pronouns is unfortunate, but I'm \n \nI don't think anyone could claim that Fred Flintstone is a positive role model... \n \nDave
598SUGGEST

Is Wilma saying “Charge it!” somewhat stereotypical?

2011-01-25Yes, but it's what she said... :)
246TYPO

Is “There’s nothing like a cheating coed teaching code.” appropriate humor?

2011-01-25Exactly what do you find inappropriate about this? \n \n
100TYPO

First paragraph in 6.1 is missing a closing parenthesis after 2^62-1

2011-04-12
392TYPO

line 5-6: “initialize_cloneinitialize_copyinitialize_dup” is not a method. (Maybe a bug, rather than a typo…)

2011-04-12
53TYPO

The last line of the example output shows “4 tests, 6 assertions”, but the final sentence of the following paragraph reads “The results show that five test methods ran, successfully executing five assertions.”

2011-04-12
59TYPO

The last line on the page, describing how a method name can be passed to inject, is flagged with 1.9, but the examples also work in Ruby 1.8.7.

2011-04-12
376OK

“There’s a wrinkle to when it comes to method definition and class inheritance” sounds very awkward. Maybe drop the word “to”.

2011-04-12Must be my English background, but it sounds OK to me...
739ERROR

Clicking in the sidebar on the Time entry for the Built-in Classes section takes you to the Time entry in the Standard Library pages.

2011-04-12
99OK

I do not know which “Version of Book” I’m reading, I don’t know where I can get this information from.

In the first example for mixins the printed example and the downloaded file do not match completely. In the downloaded file you have a second Module “D” which implements the initialize and to_s functions. Futhermore you’ve only written (in both, the book and file):

ph.who_am_i?
et.who_am_i?

instead of

puts ph.who_am_i?
puts et.who_am_i?

hence when you execute the downloaded file (as is) you get an empty output.

2011-04-12
49OK

On this page, as part of the example for array a, the following lines are given

a[1, 1] = [ 9, 8, 7 ] -> [1, 9, 8, 7, “dog”, “cat”, 9]
a[0..3] = [] -> [“dog”, “cat”, 9]
a[5..6] = 99, 98 -> [“dog”, “cat”, 9, nil, nil, 99, 98]

These lines are wrong and should be
a[0..3] = [] -> [9]
a[5..6] = 99, 98 -> [9, nil, nil, nil, nil, 99, 98]

Have a nice day :D

2011-03-15I believe the example is correct
267TYPO

“Additionally, Ruby detects any files that start with a UTF-8 byte order mark (BO).”
“BO” should be “BOM”

2011-04-12
71OK

The compact version of iterating through the top_five should be

top_five.map { |word, count| puts “#{word}: #{count}” }

2011-04-12It is correct as it is...
535ERROR

The "" method's description states that two Hashes are considered equal if, along other conditions, they have the same default value. I did not find this in the documentation of Hash itself and checking on both ruby 1.8.7 and 1.9.2 I get this: Hash.new(1) Hash.new(2) # => true
Hash.new(1).default == Hash.new(2).default # => false

2011-04-12Indeed, this was removed in in later 1.9 interpreters.
526OK

You mention Class constants for floating point types and you go on to describe the ROUNDS constant stating
“ROUNDS The rounding mode for floating-point operations. Possible values
include –1 if the mode is indeterminate, 0 if rounding is toward
zero, 1 if rounding is to nearest representable value, 2 if rounding
is toward infinity, and 3 if rounding is toward minus infinity.”

But nowhere is it mentioned how you would go ab out setting those constants. Might be helpfull (to me :)) if you did.

2011-04-12You can't set them—they're constants, set by the environment in which you run.
149OK

I’m going to make this an “error” instead of a suggestion because I feel it is rather critical.

The description of the if and unless statement needs to define what is returned if the condition is not met and there is no else clause.

Or, to rephrase, what does the “if” statement return if the condition is false and there is no else part. e.g.

dog = if false
21
end

It appears the answer is “nil” based upon my experimentation but it would be nice to know for sure what the language defines. A more everyday example:

def whaky
unless (a = some_arrays).empty?
a[0]
end
end

a[0] is returned if a is not empty but what is returned if a is empty? This sort of construct is seen fairly often.

2011-03-15To be honest, I don't know if it is defined. nil sounds plausible, but that might just be an implementation choice rather than a language specification.
474ERROR

second example usage of chunk with a state parameter is missing the closing parentheses ‘)’:
enum.chunk( state{ | element, state | . . . }

2011-04-12
712ERROR

header lines for methods to_c, to_f, and to_r have the result types mixed up: for example, the entry for to_c claims that the result is float instead of complex

2011-04-12
16TYPO

In the command-line formatting example, shouldn’t the words progname and arguments be in italics?

2011-04-12
27TYPO

The section heading “Source code from this book” is between 1.2 and 1.3 and has no number. On page 24, it’s referred to as “skip forward to Section 1.2, Source Code from This Book, on page 27”.

2011-04-12
102TYPO

6.times example on page 100.

The example is 5.times

2011-04-12
331SUGGEST

“The value of a parallel assignment is its set of
rvalues.”

I don’t think you mean class Set. Perhaps “… is an array containing its rvalues.” ?

2011-04-12
482ERROR

The doc line for Enumerable#minmax_by shows:
enum.minmax_by {|a,b| … } ➝ [min,max] or enumerator
but the block for minmax_by only has one parameter
enum.minmax_by {|item| … } ➝ [min,max] or enumerator
as shown correctly in the examples.

2011-11-03
481ERROR

The doc line for Enumerable#min_by shows a two-argument block. Like #max_by, it should be a single arg.
enum.min_by { | item | . . . } → obj or enumerator

2011-11-03
747ERROR

In 1.9 the Time#to_s method doesn’t return in the format as outlined in the book:

it “ouput of #to_s is different in 1.8 and 1.9” do
time = Time.at(1289349987)
time.strftime(“%a %b %d %H:%M:%S %z %Y”).should eql(‘Wed Nov 10 01:46:27 +0100 2010’) # passes
time.to_s.should eql(‘Wed Nov 10 01:46:27 +0100 2010’) # fails
end

Failure/Error: time.to_s.should eql(‘Wed Nov 10 01:46:27 +0100 2010’)
expected “Wed Nov 10 01:46:27 +0100 2010”
got “2010-11-10 01:46:27 +0100”

ruby -e ‘puts Time.at(1289349987).to_s’ # should return “Wed Nov 10 01:46:27 +0100 2010”

‘correct’ in :

- ruby-1.8.7-8378

- jruby-1.5.3
- rbx-1.1.0

‘failed’ in:

- ruby-1.9.1-p378

- ruby-1.9.2-p0
- ruby-1.9.2-p180

From the rubydoc ruby-doc.org/core/classes/Time.html

Returns a string representing time. Equivalent to calling Time#strftime with a format string of
``%Y%m%d %H:%M:%S %z’’ for a local time and ``%Y%m%d %H:%M:%S UTC’’ for a UTC time.

Time.now.to_s #=> “2007-10-05 16:09:51 +0900”
Time.now.utc.to_s #=> “2007-10-05 07:09:51 UTC”

2011-11-03
201SUGGEST

The ts_spec.rb code listing seems to have lost the “basic scoring” parameter to the describe method.

2011-11-03
212SUGGEST

“It’s a rapidly changing field, so we recommend a quick web search rather than rely on the advice here.” I think this should either read “…we recommend you do a quick web search…” or “…rather than relying on…”

2011-08-30To my eye, the "you do" is implicit.
225ERROR

There appears to be an extraneous } at the end of the -i usage example.

2011-11-03
227SUGGEST

“Overrides default name for TCL shared library or DLL.” The correct capitalization should be: Tcl.

2011-11-03
270TYPO

“Sets the internal debug level to $n$.” Markup misformat?

2011-11-03
310TYPO

First sentence under “Integer and Floating-Point Numbers” is missing a space after it.

2011-11-03
344SUGGEST

“This is done by calling the method classexpr.allocate.” The method name ‘allocate’ probably should not be italicized.

2011-11-03
344OK

“If a class definition overrides the class method new without calling super, no objects of that class can be created, and calls to new will silently return nil.” I’m not sure that’s entirely accurate, since objects can be created with classexpr.allocate. They can’t easily be initialized by calling the initialize method, however, because that method is normally private.

2011-09-19True 'nuf, but calling allocate directly is something of a pathological case :) \n \nIn the text, the emphasis was really the other way—if you override +new+, you should remember to call +super+.
346SUGGEST

“Although include is useful for providing mixin functionality, it is also a way of bringing the constants, class variables, and instance methods of a module into another namespace.” This sentence seems redundant and confusing. Doesn’t bringing constants, class variables, and instance methods into another namespace exactly describe the mixin functionality?

2011-11-03
349TYPO

“The returned is the value (or values) passed to next, or nil if no values are passed.” Should be “The value returned…”? Or “The return value…”?

2011-11-03
433ERROR

Method count: “Returns an Enumerator if neither an argument nor a block is given (which seems strange…).” This doesn’t appear to be accurate. The return value instead appears to be a count of all objects in the array (same as length).

2011-11-03
799TYPO

In fixing erratum #46074, there’s a new typo: mixon instead of mixin. Also, please add the word “parent” before the word “class” in each of the next two sentences. This makes it match the list of three ways in the previous sentence.

2011-11-03
140TYPO

The subtitle on this page reads “for … fn” while I believe it shoule read “for … in”

2011-11-03
746ERROR

Figure 27.17 does not include the %z (note lowercase) directive. Yet this is what is actually used in time.to_s as incorrectly described on p 747, and corrected in the errata for p 747.

2011-11-03
343OK

I think “A classname with a leading scope operator places that class or module in the top-level scope” should read “A classname without a leading scope operator places that class or module in the top-level scope”

2011-11-03It's correct as it stands. If you define \n \n class ::Dave; end \n \nten Dave will be placed at the top level, regardless of where is it defined.
139SUGGEST

“just about everything is an expression” - everything or nearly everything? What are the exceptions?

2011-09-19I think it would disrupt the flow to go into technical details here—it would involve introducing a lot of things that are forward references.
148OK

A range such as exp1..exp2 will evaluate as false until exp1 becomes true. The range will then evaluate as true until exp2 becomes true.

— second sentence first true should be false

2011-09-19I believe it is correct as it stands.
7373OK

The Fibonacci sequence is wrong. Should be 0, 1, 1, 2, 3, 5 ….

2011-09-19AGreed, but I can live with the 1, 1 version... :)
176OK

Fibers can be resumed only in the thread that created them.
- Whats a thread?

2011-09-19A forward reference of a page... :)
68OK

ugly_word_count.rb listing, line 4:

raw_text is an array due to the use of %w{}, which results in ‘undefined method ’downcase’ for Array’ error.

2011-09-19There's not %w in the text.
326OK

8th line of the top of the page

a.get_var # => “top level variable”
is wrong. @var is reassigned value 123 by Holder's class method. (first line on the page) now @var (even in the global scope) points to 123

2011-11-03The output in the book is correct. It's all part of the mess that are @@ variables in Ruby.
703TYPO

Very last line on the page: sym.to_s should return a value.

2011-11-03
28ERROR

> Exit an irb session by typing exit or by using
> the end-of-file character on your operating system
> (normally Ctrl+D or Ctrl+Z).

On Windows, the end-of-file character is Ctrl+Z but you have to use Ctrl+D to exit irb.

2011-11-03
295TYPO

Missing quotation mark after path to ruby.exe.

Currently:
“ftype RubyScript=”C:\\ruby1.9\\bin\\ruby.exe 1*

Should read:
“ftype RubyScript=”C:\\ruby1.9\\bin\\ruby.exe" 1*

2011-11-03
25ERROR

They’ve changed the location of the rvm installation scripts.

You can add -L to the curl command to follow the redirects, or go to the beginrescueend.com/rvm/install page and get the updated links from there.

2011-11-03
122TYPO

On page 122 (print4), the backslash sequence with a grave accent ( \\`) uses in fact the Unicode character (\\u2018, LEFT SINGLE QUOTATION MARK) instead of the character \\u0060 GRAVE ACCENT (also supported in ASCII-7BITS). Both characters look almost identical but the Ruby interpreter treats them differently. Obviously, this is not an issue for the paper version. However, if one wants to copy-paste the backslash sequence directly from the pdf file to a Ruby source file, this will result in an error.

2011-11-03This is an artifact of our typesetting system—in body text, it maps backquotes to the unicode variant. I'm afraid we'll have to live with that.
173ERROR

In the HTTP code example there is an incorrect part of the path in the parameter given to the get method. The http.get(‘/titles/ruby3/programming-ruby-3’) will return a message of “Moved Permanently”. The path should read ‘/book/ruby3/programming-ruby-3’ or I also discovered that ‘/book/ruby3/programming-ruby-1-9’ works.

2011-11-03
1TYPO

Title page says “Updated for Ruby 1.9.2” in the top right corner. Should say “…1.9.3” now.

2012-07-13
553TYPO

s/8BUT/8BIT/

2012-05-09
442TYPO

Examples for repeated_permutation say “repeated_combination” instead of “repeated_permutation”.

2012-05-08
696TYPO

In the definition of the String#[] method, this:

“If a name follows the regular expression, the corrsponding named match is returned”

should read as:

“If a name follows the regular expression, the corresponding named match is returned”

2012-05-09
647ERROR

The description of the sleep method says “An argument
of zero causes sleep to sleep forever”. And the signature shows 0 as the default value of the argument to sleep. In fact, an argument of 0 causes sleep to sleep for 0 seconds, i.e. not at all. Fortunately the default value of the argument to sleep is nil, which does cause sleep to sleep forever!

2012-05-09
190OK

In the sentence after the heading “Assertions == Expected Results”, there is a missing word “a” before the word “series”. It should read, “Rather than have you write a series of individual if statements …”.

2012-05-08Actually, I meant multiple series....
660TYPO

In the description of the daemon method, first sentence, parenthetical expression, you have misspelled setsid. You have Process.setssid instead of Process.setsid.

2012-05-09
7TYPO

In “The Socket API” in the last sentence on page 7, the word “local” is misspelled as “locat”.

2012-06-21
464TYPO

The return type of Complex#to_i should be integer. “complex.to_i -> float” should be “complex.to_i -> integer”

2012-05-08
473TYPO

“Encoding.find(name) \\returnsenc” should be “Encoding.find(name) -> enc”.

2012-05-09
522TYPO

In File::Stat#world_readable?, “File.world_readable?(filename) -> …” should be “statfile.world_readable?(filename) -> …”. The examples are also “File.world_readable?(…” should be “File.stat(…).world_readable?”.

There are the same typos in File::Stat#world_writable?.

2012-05-09
78ERROR

The line `triangular_numbers = Enumerator.new do |yielder|` is not correctly indented.

2012-05-08
189OK

cool book, I really like it

but
roman << code unless count.zero?
seems to be incorrect

count.times { roman << code }
is better, I think

because if I write r = Roman(1)
and r = Roman(2)
I get i
try

2012-02-27(as I show two pages on... it's a deliberate mistake)
710ERROR

The documentation for String#ord states in part “Note that it isn’t quite the inverse of\tInteger#chr, because the latter does not deal with encodings.” However, Integer#chr does take an Encoding argument. So, for example, assuming UTF-8 encoding, “ありがと”.ord.chr(Encoding::UTF_8) should == “あ”. The argument to chr would be unnecessary if the -U command line option were given.

2012-05-09
529TYPO

“flt obj \\returnstrue or false" should be "flt obj -> true or false”

2012-05-09
456ERROR

(This might be more of suggestion for clarifying the content.)

In the description of the Binding class, the text says:

“The variables, methods, value of self, and possibly an iterator block accessible in this context are all retained.”

That sounds like you can access the methods as they were where/when the binding is created, which is not necessarily the case. If the example Demo class were originally defined with a `:hullo_world` method that is modified by re-opening the class definition after setting `b1 = k1.get_binding` (`b1 = …` is from your example), running `eval ‘hullo_world’, b1` would use the new definition of :hullo_world.

Or if `:hullo_world` were only added to the class after the binding is created, running `eval ‘hullo_world’, b1` would still use the new definition of `:hullo_world`.

Does that make sense? …It’s really the scope where the binding is made that is retained and not necessarily all the items available at that point.

Unless I’m misunderstanding everything! Send me a quick email if that’s the case so I know?

Thanks!

Scott

2012-05-08I changed it to say "access to the....":
536OK

Hash.[] has an important third form, which is not documented here:

Hash[ [ [key, value], … ] ] → new_hash

see

www.ruby-doc.org/core-1.9.3/Hash.html#method-c-5B-5D

2012-05-09Their example is actually \n \nHash[ [ [ 1,2], [3, 4] ] ] \n \nThey are passing a single array argument, whose .to_hash method is then called
554TYPO

“File.new(…” should be “IO.new(…”

2012-05-09
355355OK

(which must start on the same source line as the last line of the method call)

i think phehaps fixed to:

(which must start on the same source line as the last argument of the method call)

2012-05-08I think that's also a little suspect, given the last argument can span multiple lines. I think the meaning is clear.
157SUGGEST

Dave,

Your use of caller[1..–1] deserves more explication elsewhere in the book so that users will learn to use range i..-j in array element reference. Use of –1 to mean the final array index is useful and important. You have introduced array indices that were negative, and ranges a..b with a and b negative and a<b, but I don’t see any explicit explanation of array[i..j] with i being positive and j negative. Nor do I see it covered in the Range or Array class documentation. In the Range documentation, one might think that 0..–1 never yields. And puts (0..–1).to_a.inspect doesn’t help one to learn this special case.

Love your book. Best wishes. Walter.

2012-02-27I think I'm happy the way it is—the two elements of the range are independentRuby is simply using the range in this instance as a way of packaging two numbers.
137OK

mid-page. Regarding ||=, it seems to me that the assignment does take place when the variable was already set to nil or false. I am using ruby-1.9.3-preview1.

2012-05-08By set, it means not a false value (nil or false)
106OK

mid-page. The book gives the result of show_regexp(string, /\\p{Greek}/) as the pi character, whereas the first delta character matched for me. Perhaps it depends on the unicode code point of the delta character actually entered in the string?

2012-02-27It does indeed.
41TYPO

The example of a while loop has a combination of conditions and init values that will not allow a single iteration.

I suppose, either num_pallets should be preset to 1 instead of 101 or the limit should increased from 30 to 300.

Original code below:

num_pallets = 101
weight = 1
while weight < 100 and num_pallets <= 30
pallet = next_pallet()
weight += pallet.weight
num_pallets += 1
end

2012-05-08
614OK

define_singleton_method : obj.define_method => obj.define_singleton_method

2012-05-09I can't find this
370TYPO

Sentence at end of fifth paragraph, “The Kernel module does defines puts” should read “does define puts.” Define not defines.

2012-05-08
624ERROR

singleton_method_added, singleton_method_removed, and singleton_method_undefined appear to be inherited from BasicObject.

2012-05-09
455SUGGEST

BasicObject ! method: in sentence “Returns false unless obj is false”, I believe you meant the second ‘false’ to be in Roman font, being false or nil.

2012-05-08
613OK

additional (Kernel public) instance methods:
<=>
initialize_clone
initialize_dup
respond_to_missing?
singleton_class

2012-05-09These are documented
623SUGGEST

additional Object private instance methods:
gem_original_require
initialize_copy
get_methods

2012-02-27There are a few methods such as these that I choose to ignore because they are basically intended for the implementors, and not the rest of us folk.
456ERROR

Is BasicObject method_missing a private instance method and should not have a receiver?

2012-05-08
588TYPO

Module class_variable_set: “Returns” should be “Sets”.

2012-05-09
589TYPO

Should Module const_missing show a receiver, since it seems to be a public instance method, though Ruby might only invoke it on self?

2012-05-09
592TYPO

Module module_eval: mod.class_eval(…) should be mod.module_eval.

2012-05-09
461OK

Isn’t Class.inherited an instance method (of class Class) not a class method: Class#inherited, cls.inherited?

2012-05-09Unless I'm looking at the wrong place, it is listed as a private instance method
478OK

additional Enumerable public instance methods:
chunk
collect_concat
each_entry
flat_map
slice_before

2012-05-09These are documented in the later printings and ebooks
482SUGGEST

Enumerable.inject: suggest adding the (5..10).inject(:*) example (as from page 60).

2012-05-09
483TYPO

Enumerable.none?: the parenthesized clause copied from .any? needs to be fixed for .none? .

2012-05-09
488OK

additional Enumerator public instance methods:
feed
inspect
next_values
peek
peek_values

2012-05-09These are documented
439SUGGEST

some additional Array public instance methods (some seem to override Enumerable):
collect
drop
drop_while
first
hash
include?
inspect
keep_if
map
reject
repeated_combination
repeated_permutation
rotate
rotate!
select
select!
sort
sort_by!
take
take_while
zip

2012-02-27I chose not to document these, as they are (to the best of my knowledge) simply an implementation detail. They act as if they were the enumerable versions
295TYPO

Trailing ‘}’:
<%= ruby expression %>}

2012-05-08
539OK

IO::foreach : io.foreach should be IO.foreach.

2012-05-09I can't find this
274OK

In .irbrc file
IRB.conf[:PROMPT][:MY_PROMPT]
Then use
$ irb —prompt my-prompt
Thus sentence “(Notice how the name of the prompt mode is automatically converted to uppercase, with hyphens changing to underscores.)” is inverted?
Surly it should read “converted to lower case, with underscores changing to hyphens”?

2012-05-08The prompt you type on the command line is converted....
508TYPO

File: I don’t think lchmod and lchown are presently instance methods though they are class methods.

2012-05-09
349OK

“The first two styles of Proc object are identical in use. We’ll call these objects raw procs. The third and fourth styles, generated by lambda and ->, add some functionality to the Proc object, as we’ll see in a minute.”

There are only three styles mentioned (Proc.new, lambda and ->)

2012-05-08See the previous page—there's also passing a block to a method with an ampersand parameter
660TYPO

The documentation for Process.daemon refers to the daemon(2) system call but it appears to be daemon(3). The link in the pdf results in an unsuccessful search.

2012-05-09
540TYPO

default_proc=
Sets the proc to be called to calculate values to be returned when an array is accessed with a key 1.9 it does not contain.

Should be:
Sets the proc to be called to calculate values to be returned when a hash is accessed with a key 1.9 it does not contain.

2012-05-09
545TYPO

for select! - the description should say “hsh” not “arr”.

2012-05-09
632TYPO

The Object#untrusted? method signature; “obj.untrusted -> true or false” should be “obj.untrusted? -> …”

2012-05-09
182TYPO

Paragraph beginning “We create 10 threads…” - fourth sentence (“The reason is that…”) in a tangle. “Continue” misspelled in third from last sentence. Possessive ‘its’ with apostrophe in sentence following.

2012-05-08
858TYPO

In the 2nd line of tk library description, “~” between “OS” and “X” should be a space; “Window, Linux, Mac OS~X, and other …” should be “Window, Linux, Mac OS X, and other …”.

2012-05-09
333ERROR

In “Ranges in Boolean Expressions,” the account of the flip-flop mechanism does not tally with the samples (which do agree with the output from IRB). Also, the subheading reads “if expr1 .. expr1 / while expr1 .. expr1” rather than “if expr1 .. expr2 / while expr1 .. expr2.” Though the following may be clumsily written compared to the rest of the book, it does at least describe what actually happens:

#Ranges in Boolean Expressions

\tif expr1 .. expr2
\twhile expr1 .. expr2

A range used in a boolean expression acts as a flip-flop. It has two states, set and unset, and is initially unset.

In the three-dot form, when the condition is executed and the flip-flop is unset, Ruby checks the truth of expr1. If true, the flip-flop becomes set and the condition returns true.

When the condition is executed with the flip-flop set, Ruby checks the truth of expr2. If false, the expression returns true and the state of the flip-flop remains set. If, on the other hand, expr2 returns true, the condition still returns true but the flip-flop is unset.

The two-dot form works the same way, except that the state of the flip-flop does not change from unset to set if expr1 is true but expr2 is also true.

2012-05-08
347OK

Just a guess, but is “…same logical line as the end of the invocation” supposed to be “same lexical line”? Hope so, cos if not I’m missing something.

2012-05-08I meant it in the sense of "logically on the same line" as it could in theory appear after a \\ on the next line. I agree lexical line is more accurate, but I think it's also more confusing. I changed it to "logical source line"
364ERROR

Page 364 implies that:

names = %w{ant bee cat}
result = names.map(&:upcase)

only works on 1.9, this seems to work on 1.8.7 also.

2012-06-21
910OK

The index entry for the “Set” class reads something like

Set class: 430-433, 839

However, the Set class is only documented on page 839; the earlier pages are about the Array class.

2012-07-13This one's a close call—the index entries point to set operations performed within the array class. I think I'll leave it as it.
62OK

String example is confusing if you assume that Strings are mutable, as they are in Java. Might want to mention this difference.

2012-06-21Ruby strings are indeed mutable.
503TYPO

It says that File.fnmatch is an alias for Dir.fnmatch. Did you mean Dir.glob? Dir.fnmatch does not exist.

2012-06-21
210SUGGEST

In figure 14.3, the description of the ‘where’ command uses the term “stack frame” where the term “backtrace” (or perhaps “call stack”) seems more accurate.

2012-06-21
382TYPO

(from Programming Ruby 1.9 (3rd edition) > attr_accessor should be an instance method in Module)
Page 382 in v4 print, “attr_accessor is a class method defined in class Module and so is available in all module and class definitions.”

It should be a private instance method

2012-07-06
20TYPO

The example for accept_loop has nothing to do with accept_loop and is, in fact, the same as the example for getaddrinfo

26TYPO

Note: this erratum is only for the Socket Library appendix, though the report link directs here.

the ipv6only! method is misspelled in different ways in the heading and the signature (a - is invalid and it has no _), though the source is accurately reprinted

68OK

Chapter 7 , ugly_word_count.rb

This is meant to show the top 5 most frequent words, but the loop attempts to iterate 6 times, causing an error because the last time it encounters a nil value in the hash.

for i in 0..5 should be for i in 0..4

This error is repeated at the start of section 4.3 on pdf page 70

2012-07-06There are three dots in the range, so it runs from 0 to 4
33SUGGEST

At the end of the paragraph describing instance methods is the following sentence: “If the variable my_way referenced a particular Song instance, you’d be able to call that instance’s play method and play that song”. There is no other mention or use of a ‘my_way’ variable nearby and so I was momentary confused, thinking I had missed something (perhaps I still am). I think the sentence could just read: “If a variable referenced a …”

2012-07-13
721ERROR

Margin alignment is erratic in the PDF. In a quick check, this appears to be pervasive throughout the entire document, impacting even vs. odd pages. Presumably this is an artifact of margin offsets for bound printing that’s crept into the PDF. Other Pragmatic PDFs don’t exhibit this and it’s visually distracting in the PDF rendering.

I have an illustrative screenshot, but the errata apparently don’t allow links. Contact me directly as needed for more information.

2012-07-24
811SUGGEST

Please bring back the per-letter sections of the PDF table of contents for the index. In P4.1 the Index section of the PDF had an expandable table of contents with sections A, B, C, etc. It made it a lot faster to look things up in the index. With P4.2 I have to start at the top of the index and scroll down. Not fun when I’m looking for zero? or the like.

2012-07-14They'll be in the next release. I hadn't realized that _none_ of our titles had this since we moved to the new toolchain, so thanks for pointing it out.
411SUGGEST

For the Library Reference chapter it is the same as for the index: Please bring back the subsections in the PDF table of contents (which were there in P4.1). Otherwise I have to scroll through the whole library reference (or at least through the alphabetical listing in the beginning of it) when I want to look up a specific class.

2012-07-14It'll be back in the next release
24TYPO

Near the top of page 24, there is an example following the statement: Similarly, while statements are terminated with end:

num_pallets = 101
weight = 1
while weight < 100 and num_pallets <= 30

end

Since the point of a while statement is obviated if the condition is never true, it is obvious that something is wrong with either the initial value of 101 for num_pallets or the value of 30 that it is tested against.

Since the body of the while statement increases num_pallets on every loop, it’s possible that the test value was meant to be 130 or some other value that allows the while statement to be entered (eg, not less than 101).

Or possibly the comparison operator was meant to be >= (although that condition won’t ever fail so it’s of no value).

Checking my old copy of Programming Ruby, I see that the while statement has been transferred without change from the original and only the lines providing initial values for weight and num_pallets have been added.

So probably the initial value of num_pallets was not meant to exceed 30 — 10 and 11 are plausible values (and 1 a slim possibility) if 101 is a typo.

In any case, for this while statement to be plausible, then both weight and num_pallets should pass the initial condition and conceivably either variable could fail its test condition first.

Since the weight of the pallets might be anything, I suspect that a theoretical weight of approximately 5 pounds and a probable cycle of 19 or 20 loops provide the inconsequential back-story to this example, making both 10 and 11 suitable starting values.

Personally, I would set the test condition at a smaller value than 30 — maybe 5 or 10 (30 pallets seems like too large a number to be carrying around, whatever it is that’s stacked on a pallet) and the initial value at 1.

Then the example seems like a plausible algorithm for stacking pallets on a forklift — don’t exceed this weight or this number, but go as close as you can to the maximum — and consequently a real case for using a while statement.

In any case, what a wonderful book this is!

Thanks!
Roger Sperberg

2012-07-20
411ERROR

In “Part IV—Ruby Library Reference”, the PDF index no longer lists each class/method, as in previous versions.

2012-07-17
207TYPO

Section 15.1 Command-Line Arguments - In-place Editing:

There’s a line that reads:

“This all means that if you can a
program such as this:”

Typo?

2012-07-20
1OK

The Table of Contents for the PDF no longer contains any details. Here are 2 images showing the change in styles.

Previous style: dl.dropbox.com/u/14483515/Screenshots/previous.png

New style: dl.dropbox.com/u/14483515/Screenshots/new.png

2012-07-24Tjis was fixed a few days ago. Try downloading from our site again.
110SUGGEST

At the end of chapter 7.4, please put in a reference table that has all the known patterns. If I need to decode a regular expression, I need such a table. It should include all the (?x expressions, all the \\x classes, etc.

2012-07-24It's in the language reference chapter.
92ERROR

I believe that the second example should assume another value like 9.5, for example. Assuming 5.2 will not trigger the else clause.

2012-07-24Good catch!
308SUGGEST

Please follow the discussion here: bugs.ruby-lang.org/issues/6810 to see how it turns out. For me, this is a rather fundamental change in how I view A::B and what it actually does.

2013-02-20
370OK

I do not get the expected output (“Dave lives in Texas and likes Programming Languages”) for the example in the page.

1.9.3p194 :005 > class Person < Struct.new(:name, :address, :likes)
1.9.3p194 :006?> def to_s
1.9.3p194 :007?> “#{self.name} lives in #{self.address} and likes #{self.likes}”
1.9.3p194 :008?> end
1.9.3p194 :009?> end
TypeError: superclass mismatch for class Person
\tfrom (irb):5
\tfrom /Users/katz/.rvm/rubies/ruby-1.9.3-p194/bin/irb:16:in `


1.9.3p194 :010 > dave = Person.new(‘Dave’, ‘Texas’)
=> #<struct Person name=“Dave”, address=“Texas”, likes=nil>
1.9.3p194 :011 > dave.likes
=> nil
1.9.3p194 :012 > p dave
#<struct Person name=“Dave”, address=“Texas”, likes=nil>
=> #<struct Person name=“Dave”, address=“Texas”, likes=nil>
1.9.3p194 :013 > p dave.to_s
“#
=> “#

2013-02-20Looks like you already had a Person class defined
83OK

third last line should be
0o377 => 255
instead of
0377 => 255

2013-02-20I believe it is correct as it stands
811OK

The index entry for %{…} takes me to 298 but it should take me to the table on page 296.

I have a hard time using the book as a reference guide. If possible, please consider the experienced programmer needing to look up things quickly.

2013-02-20It takes you to 298 because that is the specific use of %{...}
224OK

test in book is:

context “specifying words and a dictionary” do
should “return the words” do
opts = Anagram::Options.new([“-d”, “mydict”, “word1”, “word2”])
assert_equal [“word1”, “word2”], opts.words_to_find
end
end

should it not read:

context “specifying words and a dictionary” do
should “return the words” do
opts = Anagram::Options.new([“-d”, “mydict”, “word1”, “word2”])
assert_equal [“-d”, “mydict”, “word1”, “word2”], opts.words_to_find
end
end

2013-02-20I believe it is correct as it stands
145OK

In the first example of 10.4 catch and throw (bottom of page), you have;

puts result.reverse

Should that not be;

puts result.sort.reverse

2013-02-20I think it is OK—it prints the words in the reverse order to that in which they were added.
154SUGGEST

11.5 Parsing HTML

The Hpricot GEM is no longer maintained (github.com/hpricot), perhaps this section should be updated to use an alternative, or removed.

2013-02-20
529TYPO

Under the documentation for IO.binwrite, it says:

“options is an optional hash used to pass parameters to the underlying open call used by read.”

Should “read” be “write”?

2013-02-20
545ERROR

IO#set_encoding takes an options argument for specifying encoding behavior.

2013-02-20
157TYPO

In the “Creating Ruby Threads” section, the first example iterates over the “page” variable when it should uses “pages” as defined earlier.

2013-02-20
350TYPO

In the first line of the last paragraph, change “practic” to “practice”.

2013-02-20
232TYPO

In the parenthetical sentence about half-way down the page, remove the comma from “another, significant use”.

2013-02-20
50SUGGEST

The use of the exclusive range operator had me thinking there was a typo/off-by-one error. After messing with it in irb, I understand how it works. a quick mention of this might be helpful (although I sympathize that it’s hard to talk about one subject without dragging in all these other things you haven’t covered yet).

2013-02-20
742ERROR

In the description for Time.local, the text reads: “The second form accepts ten arguments . . .” The ten argument form is actually the first form shown just above.

2013-02-20
163OK

The hypothetical currency converter example, the ensure clause must be inside a begin… end.

begin
puts(exchange_rates.convert(line))
ensure
rate_mutex.unlock
end

2013-02-20It's OK as it stands—method bodies are automatically exception handlers.
60OK

In general the path:“samples” is wrong, dont exist in the zip file.

In this case: samples/book_in_stock.rb the correct path is: code/tut_classes/stock_stats .

You must correct the zip file changing ‘code’ for ‘samples’ or correct the wole book.

2013-02-20I don't see this in my edition
562OK

IO#gets describes behaviour for a negative limit argument that MRI does not adhere to and is not mentioned in online rubydoc or tested in rubyspec

2013-02-20I believe however that the book is correct: \n \n rb_io_getline_1(VALUE rs, long limit, VALUE io) \n { \n VALUE str = Qnil; \n rb_io_t *fptr; \n int nolimit = 0; \n rb_encoding *enc; \n \n GetOpenFile(io, fptr); \n rb_io_check_char_readable(fptr); \n if (NIL_P(rs) && limit < 0) { \n\tstr = read_all(fptr, 0, Qnil); \n\tif (RSTRING_LEN(str) == 0) return Qnil; \n } \n else if (limit == 0) { \n\treturn rb_enc_str_new(0, 0, io_read_encoding(fptr)); \n } \n else if (rs == rb_default_rs && limit < 0 && !NEED_READCONV(fptr) && \n rb_enc_asciicompat(enc = io_read_encoding(fptr))) { \n\tNEED_NEWLINE_DECORATOR_ON_READ_CHECK(fptr); \n\treturn rb_io_getline_fast(fptr, enc, io); \n } \n
833TYPO

Index entry for “return” has “The ii tag should not be here.” Looks like an error from the index generator.

9ERROR

Website for RVM lists old one: beginrescueend.com instead of new one rvm.io

818TYPO

The order of the modules in the Standard Library chapter in P4.0 goes OpenSSL (pg 815), OptionParser (pgs 816-817), OpenStruct (pg 818). I’m pretty sure OpenStruct and OptionParser should be switched! I’m not sure if this has been fixed in newer releases since I don’t have them.

99TYPO

show_regexp(a, /[\\d\\]/) # => see [The PickAxe>-<-page 123]

Actually this returns “no match” because the regex is looking for a digit followed by a dash which the string does not have. I’m guessing the \\d should be dropped.

48TYPO

On Page number 48, you’ve given an example of each where ‘e’ is shown. BTW: each excludes last thing.

38ERROR

inst_section={
cello: ‘string’,
clarinet:‘woodwind’,
drum: ‘percussion’,
oboe: ‘woodwind’,
trumpet: ‘brass’,
violin: ‘string’
}

this code in the end of pdf-page #38 raise error in my irb(windows 7, ruby 1.9.3):
syntax error, unexpected ‘:’, expecting tASSOC cello : ‘string’, \
syntax error, unexpected ‘,’, expecting $end

please give me some feedback on e-mail: warnabas@gmail.com

797ERROR

In the Tsort example the dependencies var in the example needs to be a:

@dependencies = Hash.new {|h,k| h[k] = []}

The last add_dependency in your example overrides the previous one without this.
You also need to tweak tsort_each_child to explicitly check for existence with this change.
And add_dependency needs changing to “+= relies_on”

I’m doing this from memory so I hope I’ve gotten the details correct!

730TYPO

CSV (STDOUT, col_sep: "|") do |csv|
should read
CSV.new(STDOUT, col_sep: “|”) do |csv|

124ERROR

The text reads, “You can place key => value pairs in an argument list, as long as they follow any normal arguments and precede any splat and block arguments.” In Ruby 1.9.3p448, I tested this. It appears that the appropriate order for arguments is as follows: 1) Regular, 2) Default, 3) More Regular, 4) Splat, 5) Key-Value Parameters, 6) Block. Therefore, key-value parameters must be specified last before a block.

140TYPO

Recardin the previus commmenters corexion, “shoule” should be spelt “should”. :)

569TYPO

In the description of IO#read_nonblock(), book says “the call may return EAGAIN and EINTR errors”. Rather than saying ‘return’, a better way would be to say it ‘raises EAGAIN and EINTR’ or even ‘raises Errno::EAGAIN and Errno::EINTR’

Categories: