From: Michael Fellinger Date: 2009-05-16T01:00:29+09:00 Subject: Re: [ANN] enumerable-extra 0.1.0 On Fri, 15 May 2009 01:08:12 +0900 "Daniel Berger" wrote: > Hi, > > Convinced that Symbol#to_proc is mostly a solution in search of a > problem, I've released enumerable-extra 0.1.0. > > = What is it? > > The enumerable-extra library overrides Enumerable#map, Array#map and > Array#map to accept a method, with optional arguments, that are > performed on every element of the list. > > For example, instead of this: > > array.map{ |e| e.capitalize } > > You can do this: > > array.map(:capitalize) # Capitalize every element > > You can also mix and match: > > array.map(:capitalize){ |e| e + 'x' } # Add 'x' after capitalizing > every element > > = Why is it better than Symbol#to_proc ? > > First, it doesn't require additional notation, i.e. no "&", no "its", > no "self" - just a method name. In my opinion, that makes the syntax > cleaner. Second, Symbol#to_proc is slow. Sorry, but Symbol#to_proc is actually the faster way since it was added into the core, so your statement is only true for < 1.8.6. Benchmark at: http://pastr.it/15719 -- ^ manveru