Project

General

Profile

Feature #8987 ยป mappi.rb

sample implementation in ruby (called mappi) - sowieso (So Wieso), 10/05/2013 11:02 PM

 
module Enumerable

def mappi *args
if block_given?
ary = []
each do |o|
ary << yield( o, *args )
end
ary
elsif not args.empty?
s = args.shift
raise ArgumentError, "first argument must be method name" unless s.instance_of? Symbol
ary = []
each do |o|
ary << o.public_send(s, *args)
end
ary
else
to_enum :mappi
end
end

end
    (1-1/1)