Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Symbol#to_proc
%w(john paul ringo george).map { |p| p.capitalize }
# => ["John", "Paul", "Ringo", "George"]
%w(john paul ringo george).map(&:capitalize)
# => ["John", "Paul", "Ringo", "George"]
class Symbol
def to_proc
Proc.new { |*args| args.shift.__send__(self, *args) }
end
end
[10, 6, 3].inject(&:*)
# => 180
class Symbol
def to_proc
Proc.new { |obj| obj.send self }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.