Skip to content

Instantly share code, notes, and snippets.

@timabdulla
Created July 9, 2012 16:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timabdulla/471c249173b23f04ab43 to your computer and use it in GitHub Desktop.
Save timabdulla/471c249173b23f04ab43 to your computer and use it in GitHub Desktop.
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