public
Fork of mynyml/every
Description: Symbol#to_proc's hot cousin. Simple and elegant alternative to using &:method with enumerables.
Homepage:
Clone URL: git://github.com/aanand/every.git
every /
name age message
file LICENSE Sun Mar 15 22:34:46 -0700 2009 Add license. [mynyml]
file README Loading commit data...
file Rakefile
file TODO Mon Mar 16 07:06:29 -0700 2009 Add TODO list. [mynyml]
file benchmarks.rb
file every.gemspec
directory examples/
directory lib/
directory test/
README
Symbol#to_proc's hot cousin. Simple and elegant alternative to using &:method with enumerables.

compare:

  enum = [1.4, 2.4 ,3.4]
  enum.map {|i| i.floor } #=> [1, 2, 3]
  enum.map(&:floor)       #=> [1, 2, 3]
  enum.map.floor          #=> [1, 2, 3]

arguments? sure:

  %w( axb dxf ).map.gsub(/x/,'y')     #=> ['ayb', 'dyf']
  %w( axb dxf ).map.gsub(/x/) { 'y' } #=> ['ayb', 'dyf']

works with any Enumerable method that takes a single-argument block:

  [0, 1, 2].partition.zero? #=> [[0], [1, 2]]
  [8, 9, 10].sort_by.to_s   #=> [10, 8, 9]