SAMS Teach Yourself Ruby in 21 DaysErrors in first printing

Here is a list of errors in the first printing.  Some affect the content, and others are cosmetic in nature.  The list does not address significant logical and organizational changes that would belong in a second edition.

It was requested that these entries be sorted in reverse order of discovery so that people need not peruse the entire list reading through material they have already seen.  This is done with all entries added July 2002 or later.

Dated entries

2008 Jan 15 Top of p. 282: Script line 12 should read either STDIN.gets or $stdin.gets instead of just gets. Without an explicit stream reference, the script will behave differently depending on the operating system in use (a reader reported it failed on Mac OSX).
2008 Jan 2 Bottom of p. 71: The total should display as 55.0, not 55 (this is because the initial value had been set to 0.0, a float, instead of 0, an integer).
2003 Mar 19 Starting with version 1.8 of Ruby, numeric literals that start with a decimal point are no longer allowed.  For example, referring to .93 raises an error unless you put a zero in front; 0.93 is the correct representation.  At least the following are affected:
  • p. 277 example code (middle of page)
  • p. 280, listing 13.4, line 15
  • p. 282, listing 13.5, line 9
  • p. 285, answer to exercise 2, line 5
  • p. 444, listing 19.12, line 9
  • p. 445, listing 19.13, line 8
  • p. 448, listing 19.14, line 10
2003 Jan 31p. 461: testing for the existence of a library by language version number is a Bad Idea (tm).  At the time of the book's writing, no Ruby 1.6.x versions supported DBM, but the situation has since changed.  It is better to test directly, using rescue, something like this:
  begin
    require 'dbm'
  rescue LoadError
    # your choice ... bail out gracefully, 
    # or work around the problem somehow
  end
2003 Jan 31p. 471, exercise #3: a late edit wasn't quite carried through.  The script name should be approx-time.rb (see pp. 455 and 473).
2003 Jan 21p. 436: the second sample http_file() method won't work, because the scope of the variable contents is too small.  It can be fixed in any of several ways (note that this exact sort of error is discussed on the top half of page 151).
2002 July 28p. 288: the third line of the code example, which appears blank, should read:
    paths.map do |d|
2002 July 28Last sentence of p. 287: instead of files, the correct variable name is simply f (see solution of exercise 6, middle of same page).
2002 July 28Middle of p. 271: in the comment line that reads output: none, but gb now refers to..., the variable name should be gr.
2002 July 28p. 158: The "auxiliary" information field for Albert McHugh should be 11000001 binary, which is 177 decimal.  Two other mentions of this value are inconsistent with this (and each other).  Near the top of the page, change 185 to 177, and nearer the bottom, change the value 11000001 to 10110001.
2002 July 24 Middle of p. 125: Discussion of File class methods is substantially correct but should mention that many of them are inherited from the IO class (compare to last sentence on p. 117, which refers to instance methods).
2002 July 24 Bottom of p. 133: alternate solution to exercise #3 should mention that it requires Ruby version 1.7 or later (see description of the File.read method on p. 125).
2002 July 24 Top line of p. 241 ("end") is superfluous and should be removed.
2002 July 14 p. 341, listing 16.2: line 10 should read result.uniq (compare with line 26 of listing 16.3, p. 344).

The initial list (through June 2002)


Back