Last active
December 20, 2015 06:39
-
-
Save jordelver/6087563 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 Foo | |
def bar(arg) | |
arg.call | |
end | |
end | |
class X | |
def call | |
"Normal class" | |
end | |
end | |
Y = Class.new do | |
def call | |
"Class using Class.new" | |
end | |
end | |
Z = Proc.new do | |
"Proc!" | |
end | |
class MethodObject | |
def foo | |
"No call defined!" | |
end | |
end | |
puts Foo.new.bar(X.new) | |
"Normal class" | |
puts Foo.new.bar(Y.new) | |
"Class using Class.new" | |
puts Foo.new.bar(Z) | |
"Proc!" | |
puts Foo.new.bar(lambda { "Lambda!" }) | |
"Lambda!" | |
puts Foo.new.bar(-> { "Stabby lambda!" }) | |
"Stabby lambda!" | |
puts Foo.new.bar(MethodObject.new.method(:foo)) | |
"No call defined!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment