Last active
April 21, 2016 09:02
-
-
Save gtmax/ee220a315d6860c2a18011fa152be68f to your computer and use it in GitHub Desktop.
Symbol Monkeypatch to allow passing params to &
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment