Joshua Collins
5/14/2009 5:31:00 PM
[Note: parts of this message were removed to make it a legal post.]
Would this be usable with a RoR app?
I am not certain if RoR core needs Symbol#to_proc ... but, it would be nice
to use enumerable-extra in my Ruby coding in RoR. I am just iffy about
trying it cause I am not certain if I would break my RoR app because I
installed the gem and the gem overirides Enumberable#map and so forth.
Thanks :)
Sorry if it seems like a newb question, but I am learning both Ruby and RoR
at the same time -- so, in a sense I am a newb :-P
On Thu, May 14, 2009 at 12:08 PM, Daniel Berger <djberg96@gmail.com> 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.
>
> = How do I get it?
>
> gem install enumerable-extra
>
> = Caveat
>
> This is for Ruby 1.8.x only.
>
> Enjoy!
>
> Dan
>
>
>