-
-
Save timabdulla/471c249173b23f04ab43 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 A | |
def test(&b) | |
instance_eval(&b) | |
end | |
end | |
class B | |
def test_a(a) | |
a.test { puts self } | |
end | |
def test_b_helper(*args) | |
puts self | |
end | |
def test_b(a) | |
m = method(:test_b_helper).to_proc | |
a.test(&m) | |
end | |
end | |
a = A.new | |
b = B.new | |
b.test_a(a) #<A:0x007ff66b086c68> | |
b.test_b(a) #<B:0x007fa3e1886bc0> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment