Last active
December 26, 2015 22:19
-
-
Save ctdean/7222190 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 Foo | |
attr_accessor :color | |
attr_accessor :history | |
def initialize | |
@color = "white" | |
@history = [@color] | |
end | |
def dump | |
"color = <#{@color}>, history = <#{@history}>" | |
end | |
def reset_1 | |
color = "red" | |
history << "red" | |
end | |
def reset_2 | |
self.color = "green" | |
self.history << "green" | |
end | |
def reset_3 | |
@color = "blue" | |
@history << "blue" | |
end | |
end | |
foo = Foo.new | |
puts "start #{foo.dump}" | |
foo.reset_1 | |
puts "reset_1 #{foo.dump}" | |
foo.reset_2 | |
puts "reset_2 #{foo.dump}" | |
foo.reset_3 | |
puts "reset_3 #{foo.dump}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
results in: