’
2.1.1 :005 > Array.new.send(:new_method)
“Hey there”
=> “Hey there”
2.1.1 :006 >
By Developers, For Developers
| PDF Pg | Paper Pg | Type | Description | Fixed on | Comments |
|---|---|---|---|---|---|
| 204 | ERROR | “a ||= []” should be “a || (a = [])” instead of “a = (a || [])”. ref. www.ruby-doc.org/core-2.1.1/doc/syntax/assignment_rdoc.html | 2014-06-15 | Hello, Kado! :) \nYou're as fast as ever. I think that you gave me a heads-up about this problem in the 1st edition. I can't remember why I decided to leave the text as it is, but I'll look into it soon. Thank you! \n \nUpdate: fixed. | |
| 107 | OK | “At the top level of your program, the current class is Object, the class of main. (That’s why, if you define a method at the top level, that method becomes an instance method of Object).” As far as I can see it is not an instance method of Object but a private method: 2.1.1 :001 > self ’ | 2014-03-21 | Both are true: it's an instance method, and it is private. :) \n \n \nTry Object.private_instance_methods.grep(/new_method/). \n \nI think that originally I wrote "[...] if you define a method at the top level, that method becomes a *private* instance method of Object". However, the fact that the method is private is just a separate design choice in the language, and it's not relevant in this context. I thought that mentioning "private" could take the attention of the reader away from the important point: that the current class at the top level is Object. So I removed the mention of "private". I'll keep in mind that you find this particular point confusing. If it confuses more readers, I might consider adding a footnote, or something. \n \nBTW, Bruno, your report also made me notice something weird: while your code (correctly) breaks in irb because you're calling a private method, it seems to work just fine in Pry. I have no idea why Pry allows you to call private methods on another object in this case - maybe I'll look at that in the future. | |
| 14 | ERROR | If I run the example on this page, I get the error that Money.from_numeric is undefined - I have installed the current version (6.1.1) of the money gem. | 2014-06-15 | Anand, see your other errata about the Money gem example. | |
| 12 | SUGGEST | The example uses Test::Unit. Test::Unit is currently replaced by MiniTest (I get an error stating the same when i try to run with the example code in Ruby 2.1) - perhaps use MiniTest instead? | 2014-06-10 | Actually, both test-unit and minitest have been removed from the standard Ruby distribution (https://bugs.ruby-lang.org/issues/9711). It's strange that it doesn't work on 2.1 for you... It seems to work for me. From 2.2 onwards (the current ruby-head) I need to "gem install test-unit" to run the tests. \n \nThanks for the tip, Anand... I added a few lines to the Introduction explaining that you need to install test-unit. | |
| 14 | ERROR | to_money is deprecated in the gem money v6.1 - see money-rails/issues/150 on github. I get error “undefined method `to_money’ for 100:Fixnum (NoMethodError)” when I run the sample on this page. | 2014-06-15 | Things like this happen frequently: as soon as you print the code of an open source library, that code changes. In this case, the problem is more visible, because the core interface of the Money gem changed. Instead of adding notes and disclaimer to every example, I'll add two lines in the Introduction explaining that the examples are useful for the tricks they show, but they might not match the current version of the gem. Thank you for making me aware of this, Anand. | |
| 121 | TYPO | “I want to open this object, and I don’t particularly care it’s a class,” Missing an ‘if’ => Should be “…if it’s a…” | 2014-06-28 | ...and fixed! Thank you, Jon. | |
| 20 | TYPO | The paragraph says: I think it should say WE can ask ourselves. | 2014-06-28 | Fixed... | |
| 21 | TYPO | A variable can references a class just like any other object: I think it should be REFERENCE instead of referenceS | 2014-06-28 | ...fixed... | |
| 44 | ERROR | The code from example money_example.rb is deprecated, the money gem has bin split into money and monetize - method from_numeric must be used from Monetize module. Here is my fix (also removed second require ‘money’): GIST: a9f2bd6492ce857c3f80 Best Regards | 2015-03-04 | This is great info, Bart. Thank you - I'll update the book for the next batch of printings. | |
| 193 | TYPO | The sentence: “if the validation fails, and otherwise falls back to the original save_with_validation!.” | 2015-02-28 | Right! Fixed. | |
| 192 | TYPO | The last paragraph says: “Validation#save_with_validation But based on the validation code: “if perform_validation && valid? || !perform_validation” I think the method: will still call the original save_without_validation method if the caller explicitly disables validation since the call: save_with_validation(false) will make !perform_validation | 2015-02-28 | You're right! I replaced "or if the caller" with "unless the caller". | |
| 30 | OK | I have a question about method lookup. class B < A class Class B.method_a #=> “method_a in A” So, i think it should be “Goes up, the one step to the right”. | 2014-09-23 | Marcus, class methods look like a special case - but they actually work the same way, even if that's not easy to see. In your example, Ruby goes one step to the right into B's class (which is Class), and then up. You'll find a detailed explaination in chapter Class Definitions. | |
| 12 | OK | It says to install `test-unit` for ruby 2.2 or later. Isn’t that version (2.2) a typo? We are on 2.1. | 2014-09-23 | It's just a very new book, so I peeked in the ruby-head branch put in information that should become valid soon - as soon as Ruby 2.2 is out. :) | |
| 55 | OK | For the refinement gotchas, using MyClassRefinement returns “original my_method()” for me instead of the “refined my_method()” Refinement does not seem to work for me. I am using ruby 2.1.1 | 2015-03-04 | I just tried the example with 2.1.1, and it works for me. I'll mark this as "not a problem" for now, but feel free to open a new one if the test fails on you on the original file. To run the test, run "ruby code/object_model/refinements_gotcha.rb". | |
| 210 | TYPO | On 3rd paragraph: “(We discussed additional arguments to method_eval, such as FILE and LINE, in The irb Example, on page 144.)” method_eval should be module_eval | 2015-02-28 | Fixed. Thanks you. | |
| 95 | SUGGEST | class_eval is used in an example, but it’s only introduced later (on page 107). | 2015-03-04 | ||
| 1 | OK | The text should be updated for JRuby 9000 (“supporting Ruby 2.2, except for Refinements and a few other things”). | 2015-03-04 | This was my own errata. Then I decided that the current text already makes adequate references to non-MRI interpreters, by warning the reader that some examples might not work. So I stopped running JRuby-specific tests. | |
| 1 | ERROR | From Kado: “blocks/using.rb” on ch04 doesn’t work because Ruby 2.x has “using” method for Refinements. | 2015-03-05 | ||
| 1 | ERROR | ch03: There are “accounting” department and “purchasing” department are intermingled in the same context. | 2015-02-28 | ||
| 1 | ERROR | Introduction : “Until Ruby 2.1, test-unit was a standard library. From Ruby 2.2 onward, you need to install it as a gem” isn’t correct. 2.1 doesn’t have it (actually it is mini-test) and 2.2 has real test-unit. | 2015-03-05 | ||
| 1 | ERROR | From Kado: “blocks/flat_scope_3.rb” on ch04 has a unwanted assertion method. It seems a test code for your self. And it needs two ‘puts’ in front of the strings. | 2015-02-28 | ||
| 191 | TYPO | In the sentence “The only the first two methods include the new feature.” there is an extra “The”. | 2015-02-28 | Fixed. Thanks. | |
| 1 | ERROR | “Try defining a method inside another method with def, and you’ll see that the new method is defined on the class of self.” Not 100% accurate - in case self belongs to a subclass, the method is defined in the class of the wrapper method. | 2015-02-28 | ||
| 1 | TYPO | From Kado: Ch05: “Kernel#callers” => “Kernel#caller”. | 2015-03-04 | ||
| 194 | TYPO | In sentence “and extended defines an @_dependenciesClass Instance Variable (109) on the includer” , should includer be extender? | 2015-03-07 | Indeed it should. :) Thanks, | |
| 1 | OK | “+ Here’s how you create a It has still “Money” string. | 2016-05-15 | this is actually correct - Monetize still returns Money objects | |
| 1 | ERROR | Ch04 about Padrino: “written with the RSpec test gem” It is not RSpec but minitest. | 2016-05-15 | ||
| 1 | TYPO | From Kado: | 2016-05-15 | ||
| 1 | ERROR | On Stack Overflow: questions/29980160/metaprogramming-ruby-2-example-from-the-book-isnt-working-when-i-try-it-troubl | 2016-05-15 | ||
| 1 | ERROR | [09/06/15 15:21:19] KADO Masanori: ch02: monetise gem doesn’t work on Ruby 2.2.2. | 2016-05-15 | ||
| 1 | ERROR | appendix01: changed sample code at the point of ‘*’. class MyClass
obj.set_attribute 11 # No error!
| 2016-05-15 | ||
| 146 | TYPO | > “revert()” to explore_array, the method will evaluate the string “[’a’, ’b’, ’c’].revert()”. It’s time to try out this utility: revert() should be reverse() | 2016-05-15 | ||
| 1 | ERROR | Kado rightly observers that “the & operator” is a misnomer. It’s not technically an operator. Some people call it “the & modifier”, but I’m not sure how common this is in English. Check it, and decide whether to add a one-sentence note to the book, or even change the name altogether. | 2016-05-15 | ||
| 51 | TYPO | The last two lines in the “methods/dynamic_definition.rb” code sample are tests, and they shouldn’t appear in the text. | 2016-05-15 | ||
| 193 | TYPO | The writer is describing the “save_with_validation!” and mistakenly reuse the name again when what he meant was “save_without_validation!”. | 2020-04-02 | Thanks, Bolatan! I'll submit this for the next printings, if we get any more. | |
| ¨82 | TYPO | In the Safari Books Online edition (no page numbers available), Chapter 3, Quiz: Bug Hunt, the sample output is: | 2020-04-02 | I cannot believe nobody spotted this so far. Thank you! If we have another printing, I will fix it. | |
| 49 | OK | The Pry example is not behaving as advertised. Pry instances do not have a quiet= method, nor do they have a refresh method. Is there a specific version of Pry you are using for these examples? | 2020-04-02 | Hey, Peter! I used Pry version 0.9.12.2, which is the version that you will find in the book's source code, under the 'gems' directory. (Ruby libraries typically change fast, so I expect that some examples became obsolete soon after the book came out. To make it easier for readers to make their own experiments, I packaged the versions of gems that I used in the book with the rest of the examples.) | |
| 35 | ERROR | The example regarding private method calls no longer works on ruby 2.7. Looks like it’s caused by Ruby issue number 16783 (which I would link to, but this form doesn’t accept links) | Thank you, Szymon. Yes, I'm aware that the behaviour of private methods changed slightly in Ruby 2.7. That's one of the few corner cases where information in the book became stale. However, it's not worth for us going through indexing/typesetting again to fix those rare inaccuracies. \nIf anything, we should wait for Ruby 3, and then consider a third edition. I'll leave this erratum here in case we ever decide for that. Thank you for reporting this! |