Advertisement
Guest User

Untitled

a guest
Sep 7th, 2012
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.31 KB | None | 0 0
  1.  
  2. class A
  3.   def foo ; p "a" end
  4.   def bar ; foo end
  5. end
  6. class B
  7.   def foo ; p "b" end
  8. end
  9. B.new.instance_exec &A.new.method(:foo).to_proc # prints "a", not "b"
  10. B.new.instance_exec &A.new.method(:foo)         # idem
  11.  
  12. $p = proc do ; foo end
  13. B.new.instance_exec &$p                         # prints "b" (ok)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement