Eloquent ruby

Selected quotes from Eloquent Ruby

Inside of Hash there is special case code that makes a copy of any keys passed in if the keys happen to be strings. The fact that the Hash class needs to go through this ugly bit of special pleading precisely to keep you from coming to grief with string keys is the perfect illustration of the utility of symbols.

In Ruby, if you can reference it with a variable, it’s an object.

Any instance of a class can call a protected method on any other instance of the class. Thus, if we made word_count protected, any instance of Document could call word_count on any other instance of Document, including instances of subclasses like RomanceNovel.

also give equal time to the ActiveRecord silence method, which turns logging off4 for the duration of a code block.

The module analog of inherited is included. As the name suggests, included gets called when a module gets included in a class.

The ultimate Ruby hook, however, has got to be set_trace_func. With this handy little method you can supply a block that will get called whenever a method gets called or returns, whenever a class definition is opened with the class keyword or closed with an end, whenever an exception get raised, and whenever—and

As we have seen, you can always get the full path to your Ruby file with `FILE:

Remember, as the old bit of programming wisdom says, good code is like a good joke: It needs no explanation.

Friedl, J. E. F. Mastering Regular Expressions.

Regular Expressions Cookbook.

Test-first development is a great idea, but we in the software industry have a habit of messing up really good ideas by deciding they are not just good but absolutely universal. And required.

The composed method technique advocates dividing your class up into methods that have three characteristics. First, each method should do a single thing—focus on solving a single aspect of the problem. By concentrating on one thing, your methods are not only easier to write, they are also easier to understand.

On LISP. The entire text of this book is available at www.paulgraham.com/onlisp.html. It is worth reading even if you never type a single parenthesis of LISP.

Smalltalk Best Practice Patterns. Upper Saddle