Inject This
It’s well known now that while Ruby is solid, it’s a work-in-progress.
For instance, it’s not that DRY yet - take Class method declarations as an example:
class Foo
class << self
def bar
...
or
class Foo
class << Foo
def bar
...
or
class Foo def self.bar ...
or
class Foo def Foo.bar ...
or
class Foo end def Foo.bar ...
Sometimes though, like this occassion, I don’t think the choice is such a bad thing. It encourages you not to be brainless and use what makes sense to you.
Those who’ve worked with me know that I’m particularly sensitive to informative method names, so this one’s recently taken the cake:
Enumerable#inject
The name suggests you’re shoving something in the Collection right? Wrong! It iterates all elements with the intention of assembling a value, such as a sum.
Inject! Pffh!

February 17th, 2007 at 10:35 am
That reminds me of Perl’s “There’s more then one way to do it”. For example:
if (cond) stmt;
unless (!cond) stmt;