# # # # # # # # #
# /29/class2proc.rb
#
# by Jan Lelis
# e-mail: mail@janlelis.de
# type/version: ruby
# snippet url: http://rbJL.net/29/class2proc.rb
# original post: http://rbJL.net/29-become-a-proc-star
# license: CC-BY (DE)
#
# (c) 2010 Jan Lelis.
# Shortcut for initializing objects
class Class
def to_proc
Proc.new{ |*args|
self.new *args
}
end
end
# usage
# [[1,2],[3,5,6,7]].map &Set # => [#<Set: {1, 2}>, #<Set: {5, 6, 7, 3}>]