I’m always surprised when I see bright people writing ruby code without using ruby’s standard lib. Do I need to point out that it’s less readable and more error prone?
I plead all rubyists to re-read the doc for Array, Hash and Enumerable/Enumerator. Refer back to it. Use it. Please!
I was quite amazed to see the following code (written by an ex rails-core programmer, nothing less!). Check out the three methods and ask yourself what they do and how they should be written (mouse-over the code for the answers).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
The extract_is_cool!
method was actually not even needed because there was a merge!(options)
later on, just adding insult to injury…