Sha256: 6c0a03e1c81ad764ab73c86cb3bd2023689d6d982bedc95452c151c0dd5a7d5e

Contents?: true

Size: 481 Bytes

Versions: 10

Compression:

Stored size: 481 Bytes

Contents

module Enumerable

  # Send a message to each element and collect the result.
  #
  #   [1,2,3].map_send(:+, 3)  #=> [4,5,6]
  #
  # CREDIT: Sean O'Halpin

  def map_send(meth, *args, &block)
    map{|e| e.send(meth, *args, &block)}
  end

  #--
  # Old defintion confused me ...
  #
  #   def map_send(meth, *args) #:yield:
  #     if block_given?
  #       map{|e| yield(e.send(meth, *args))}
  #     else
  #       map{|e| e.send(meth, *args)}
  #     end
  #   end
  #++

end

Version data entries

10 entries across 9 versions & 2 rubygems

Version Path
facets-glimmer-3.2.0 lib/core/facets/enumerable/map_send.rb
facets-3.1.0 lib/core/facets/enumerable/map_send.rb
facets-3.0.0 lib/core/facets/enumerable/map_send.rb
facets-2.9.3 lib/core/facets/enumerable/map_send.rb
facets-2.9.2 lib/core/facets/enumerable/map_send.rb
facets-2.9.2 src/core/facets/enumerable/map_send.rb
facets-2.9.1 lib/core/facets/enumerable/map_send.rb
facets-2.9.0 lib/core/facets/enumerable/map_send.rb
facets-2.9.0.pre.2 lib/core/facets/enumerable/map_send.rb
facets-2.9.0.pre.1 lib/core/facets/enumerable/map_send.rb