Skip to content

Instantly share code, notes, and snippets.

@gtmax
gtmax / symbol_call_patch.rb
Last active April 21, 2016 09:02
Symbol Monkeypatch to allow passing params to &
class Symbol
# Allows to pass args to &:method_name like so:
# [1.234, 2.345, 3.456].map &:round.(2) => [1.23, 2.34, 3.45]
def call(*args)
proc do |receiver|
receiver.send(self, *args)
end
end
end