Created
November 25, 2015 10:46
-
-
Save bokuo-okubo/8f5b92a974602a6c8167 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 Person | |
@name | |
def hello | |
p @name ||= 'Michael' | |
end | |
end | |
man = Person.new | |
man.hello # => "Michael" | |
man.name # => NoMethodError: undefined method `name' for #<Person:0x007f9823877f68 @name="Michael"> | |
man.instance_eval { @name = 'John' } | |
man.hello # => "John" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment