From: Avdi Grimm Date: 2012-06-21T09:49:23+09:00 Subject: Re: Benchmark obsession? --f46d04451a09f31fc204c2f0e242 Content-Type: text/plain; charset=ISO-8859-1 On Jun 20, 2012 5:57 PM, "Ryan Davis" wrote: > > > > counter = Hash.new 0 > thingies.each do |o| > counter[o.key] += 1 > end > return counter > I'm curious if you consider #each_with_object a reasonable choice for this. -- Avdi --f46d04451a09f31fc204c2f0e242 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable


On Jun 20, 2012 5:57 PM, "Ryan Davis" <ryand-ruby@zenspider.com> wrote:
>
>
>
> =A0 =A0counter =3D Hash.new 0
> =A0 =A0thingies.each do |o|
> =A0 =A0 =A0counter[o.key] +=3D 1
> =A0 =A0end
> =A0 =A0return counter
>

I'm curious if you consider #each_with_object a reasonable choice fo= r this.

--
Avdi

--f46d04451a09f31fc204c2f0e242--