Advertisement
Guest User

Untitled

a guest
Oct 4th, 2012
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.30 KB | None | 0 0
  1. class Object
  2.     def x
  3.         "Object's x"
  4.     end
  5. end
  6.  
  7. class MyClass
  8.     x = "hello"
  9. end
  10.  
  11. def foo
  12.     Object.new.instance_eval {puts x}
  13. end
  14.  
  15. def bar
  16.     x = "Hello!"
  17.     Object.new.instance_eval {puts x}
  18. end
  19.  
  20. foo            #=> Object's x
  21. bar            #=> Hello!
  22. puts MyClass.x #=> Object's x
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement