This project is archived and is in readonly mode.

#962 ✓committed
Adam Keys

#injecting on Enumerable

Reported by Adam Keys | September 3rd, 2008 @ 11:24 AM | in 2.x

injecting makes inject easier to use. Rather than returning the accumulator from your block, the accumulator is modified in place.

Apparently Merb had this method for a while, but lost it in the rewrite. I've adapted it to Rails in an idiomatic style.

For example:


%w(foo bar).injecting({}) { |hsh, str| hsh[str] = str.upcase } # => {'foo' => 'FOO', 'bar' => 'BAR'}

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Referenced by

Pages