Created
November 24, 2012 01:56
-
-
Save ynojima/4138027 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
#!/usr/bin/env ruby | |
class InstanceVariableEval | |
attr_accessor :val | |
def initialize | |
@val = "initial data" | |
end | |
def set_from_instance_method_through_accessor | |
val = "set_from_instance_method_through_accessor" | |
end | |
end | |
a = InstanceVariableEval.new | |
puts a.val | |
a.set_from_instance_method_through_accessor | |
puts a.val | |
a.val = "set_through_accessor" | |
puts a.val | |
## Following is the output. I can't understand why val is not updated by the method "set_from_instance_method_through_accessor". | |
# initial data | |
# initial data | |
# set_through_accessor | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment