Created
January 4, 2016 03:39
-
-
Save zunda/3623491b655bb251f1d0 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 Dog | |
def name=(x) | |
trace_ivar_set(:@name, x) | |
end | |
def trace_ivar_set(ivar, x) | |
puts "#{ivar} is set to #{x.inspect} for #{self.inspect} at #{caller[1]} called from #{caller[2]}" | |
instance_variable_set(ivar, x) | |
end | |
def name_taro | |
self.name = 'Taro' | |
end | |
end | |
a = Dog.new | |
a.name_taro | |
p a |
Author
zunda
commented
Jan 4, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment