From: Simon Strandgaard Date: 2005-10-29T02:17:54+09:00 Subject: Re: Cleaner syntax for .map (is there already a way, or ruby2 idea?) Maybe this can be useful? -- Simon Strandgaard class Array def xmap(*symbols) symbols.each do |symbol| s = symbol.to_s eval "def #{s}(*args);map{|i|i.send(:#{s}, *args)};end" end end end ary = %w(a b c d e) ary.xmap(:upcase, :gsub) p ary[0].upcase # "A" p ary.upcase # ["A", "B", "C", "D", "E"] p ary.gsub(/[bd]/, 'X') # ["a", "X", "c", "X", "e"]