Created
March 14, 2014 16:44
-
-
Save banister/9551558 to your computer and use it in GitHub Desktop.
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 Blah | |
def add(x, y) | |
x + y | |
end | |
end | |
# => nil | |
class Symbol | |
def call(*args, &block) | |
->(o) { o.send(self, *args, &block) } | |
end | |
end | |
# => nil | |
ary = Array.new(5) { Blah.new } | |
# => [#<Blah:0x007fd0ff1119d0>, | |
# #<Blah:0x007fd0ff1119a8>, | |
# #<Blah:0x007fd0ff111980>, | |
# #<Blah:0x007fd0ff111958>, | |
# #<Blah:0x007fd0ff111908>] | |
ary.map(&:add.(5, 6)) | |
# => [11, 11, 11, 11, 11] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
.(
looks so wrong. Why not&:add.bind(5, 6)
? C++ flavoured ;)