Understanding Computation

Errata for Understanding Computation

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
PDF Page 11
United States

Great book! There are hardly any errors in it, which I appreciate. I did find one minor issue when I went back to the "Just Enough Ruby" section just now.

Page 11 describes behavior for map and flat_map that unfortunately no longer works because the "chars" method now returns an Enumerable, which has a different to_s and inspect. To get your output, one would have to change the commands or override to_s or inspect.

Examples in 1.9.3:

irb(main):008:0> ['one', 'two', 'three'].map(&:chars)
=> [#<Enumerator: "one":chars>, #<Enumerator: "two":chars>, #<Enumerator: "three":chars>]

irb(main):005:0> ['one', 'two', 'three'].map(&:chars).map(&:to_a)
=> [["o", "n", "e"], ["t", "w", "o"], ["t", "h", "r", "e", "e"]]

irb(main):009:0> ['one', 'two', 'three'].flat_map(&:chars)
=> [#<Enumerator: "one":chars>, #<Enumerator: "two":chars>, #<Enumerator: "three":chars>]

irb(main):010:0> ['one', 'two', 'three'].map(&:chars).flat_map(&:to_a)
=> ["o", "n", "e", "t", "w", "o", "t", "h", "r", "e", "e"]

Stephen Dewey  Dec 22, 2013 
Printed Page 32
First paragraph

Hi Tom,

Awesome book! Required reading for everyone on my dev. team.

I think Object.send(:remove_const, :Machine) can be avoided by

Machine = do

Is there a reason why the book uses

class Machine <

Thanks, Rohit

Rohit Namjoshi  Aug 31, 2013