D
Daniel Berger
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.mapcapitalize) # Capitalize every element
You can also mix and match:
array.mapcapitalize){ |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
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.mapcapitalize) # Capitalize every element
You can also mix and match:
array.mapcapitalize){ |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