On Thu, Jun 21, 2012 at 6:28 AM, Avdi Grimm <[email protected]> wrote:
> On Wed, Jun 20, 2012 at 9:07 PM, Sam Duncan <[email protected]> wrote:
>>
>> Is that basically the same thing wrapped in another method so that counter
>> and o are yielded to a block?
>
> Yes, and it's part of
> Enumerable: http://ruby-doc.org/core-1.9.3/Enumerable.html#method-i-each_with_object

Enumerable also has
http://ruby-doc.org/core-1.9.3/Enumerable.html#method-i-group_by

thingies.group_by(&:key)
thingies.group_by(&:key).map {|o,y| [o,y.length]}

Kind regards

robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

-- You received this message because you are subscribed to the Google Groups 
ruby-talk-google group. To post to this group, send email to 
[email protected]. To unsubscribe from this group, send email 
to [email protected]. For more options, visit this 
group at https://groups.google.com/d/forum/ruby-talk-google?hl=en

Reply via email to