# # # # # # # # #
# /29/array2proc.rb
#
# by Jan Lelis
# e-mail: mail@janlelis.de
# type/version: ruby
# snippet url: http://rbJL.net/29/array2proc.rb
# original post: http://rbJL.net/29-become-a-proc-star
# license: CC-BY (DE)
#
# (c) 2010 Jan Lelis.
# Uses the array as arguments for the object's send method
class Array
def to_proc
Proc.new{ |obj|
obj.send *self
}
end
end
# usage
# [1,2,3,4,5].map &[:to_s, 2] # => ["1", "10", "11", "100", "101"]