Last active
December 22, 2015 18:49
-
-
Save ngpestelos/6515639 to your computer and use it in GitHub Desktop.
instance_eval
This file contains hidden or 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
# see Metaprogramming Ruby, p. 74 | |
class MyClass | |
def initialize | |
@v = 1 | |
end | |
end | |
obj = MyClass.new | |
obj.instance_eval do | |
puts self | |
puts @v # 1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment