The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".
The following errata were submitted by our customers and approved as valid errors by the author or editor.
Version |
Location |
Description |
Submitted By |
Date submitted |
Date corrected |
Printed |
Page 31
example in "statement modifier for while" |
The sum variable doesn't belong in the example.
Omit:
sum = 0
Replace:
cash += 1.00, sum while cash < 1_000_000
With:
cash += 1.00 while cash < 1_000_000
|
Anonymous |
|
|
Printed |
Page 32
third paragraph |
The book says that when using a case statement "the logic of == is assumed". I'm pretty sure the === (triple equals, not double) is used because you can test the class of an object. For example, the following returns true:
case 65
when Fixnum: true
else false
end
which is only possible if === is used.
Note from the Author or Editor: This information submitted is correct according to p. 106 of The Ruby Programming Language by Matz and David Flanagan. However, if a class inherits from Object, == is invoked instead.
|
Alex Reisner |
Nov 04, 2009 |
|
Printed |
Page 45-46
rolling dice example |
From: Adri�n Mugnolo <adrian@giro54.com>
Date: Fri, 11 Jul 2008 16:10:25 -0300
Subject: Ruby Pocket Reference, examples on pages 45-46
Hi,
I originally sent this email regarding your Learning Ruby title and,
was acknowledged by the author. Now that I have a copy of Ruby Pocket
Reference in my hands I see the same code example listed on two pages.
Mathematically correct and idiomatic Ruby for this example should be
something like:
module Dice
def roll
r1 = rand(6) + 1
r2 = rand(6) + 1
total = r1 + r2
puts "You rolled #{r1} and #{r2} (#{total})."
total
end
end
class Game
include Dice
end
g = Game.new
g.roll
Hope this helps to improve any upcoming edition of both books.
Regards
--
Adri�n Mugnolo
Giro54
Begin forwarded message:
> From: Adri�n Mugnolo <adrian@giro54.com>
> Date: December 24, 2007 8:05:11 PM GMT-03:00
> To: bookquestions@oreilly.com
> Subject: Learning Ruby, examples 9-12 and 9-13
>
> Hi,
>
> Just a few lines about some issues with the "Learning Ruby" title,
> examples 9-12 and 9-13.
>
> Looks like the author/editor suspected something about the examples:
> "(...) Admittedly, it may not be the most efficient way to guarantee
> a nonzero result, but it works".
>
> According to Ruby's documentation: "(...) [Kernel#rand] returns a
> pseudorandom integer greater than or equal to zero and less than
> [the parameter] max1".
>
> The examples 9-12 and 9-13 have these lines in common:
>
> r_1 = rand(6); r_2 = rand(6)
> r1 = r_1 > 0 ? r_1 : 1; r2 = r_2 > 0 ? r_2 : 1
> total = r1 + r2
>
> IMO, they present several conceptual mistakes:
>
> 1. The dice model is "loaded" for 1. The frequency for 1 is 1/3 --
> twice the correct 1/6.
>
> 2. The dice model has face 6 missing. Because Kernel#rand will
> never return 6, total can't exceed 10.
>
> 3. Use of unneeded variable pairs with very similar names (r_1 and
> r1, r_2 and r2).
>
> 4. Contrived examples in a book meant for beginners, etc.
>
> Let me suggest a simpler replacement:
>
> r1 = rand(6) + 1 # Kernel#rand returns an integer between 0 and n - 1.
> r2 = rand(6) + 1 # Then, increment returned value by one.
> total = r1 + r2
>
> Other than that, the book is great. I am an long-time fan of
> everything O'Reilly: publications, conferences, etc. I spotted this
> problem while reviewing this title to be used as an introductory
> textbook on Ruby, OOP and general programming.
>
> Hope this helps to improve an upcoming edition.
>
> Best regards
>
> --
> Adri�n Mugnolo
> Giro54
|
Anonymous |
Jul 14, 2008 |
|
Printed |
Page 45-46
rolling dice example |
Mathematically correct and idiomatic Ruby for this example should be
something like:
module Dice
def roll
r1 = rand(6) + 1
r2 = rand(6) + 1
total = r1 + r2
puts "You rolled #{r1} and #{r2} (#{total})."
total
end
end
class Game
include Dice
end
g = Game.new
g.roll
|
Anonymous |
|
|
Printed |
Page 65
First line after paragraph heading "Number of operands" |
Different operands take different numbers of operands.
should be:
Different operators take different numbers of operands.
|
Anonymous |
|
Sep 01, 2007 |
Printed |
Page 99
middle |
This is not as much an error as an omission: the Array#detect method is not documented.
|
Anonymous |
Nov 07, 2008 |
|
Printed |
Page 109
Third line from bottom |
The method name should be each_pair, not each_key.
Note from the Author or Editor: This is correct. The method each_key (third line from the bottom of 109) should be each_pair.
|
Anonymous |
|
|
Printed |
Page 110
First line |
The method name should be each_value, not each_key.
Note from the Author or Editor: This is correct.
The method name on the first line of p. 110 should be: each_value.
|
Anonymous |
|
|