Skip to content

Instantly share code, notes, and snippets.

@banister
Created March 12, 2012 06:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save banister/7b3eebac113e42515f87 to your computer and use it in GitHub Desktop.
Save banister/7b3eebac113e42515f87 to your computer and use it in GitHub Desktop.
class Hello
attr_accessor_with_history :baby, :got, :back
end
# => [:baby, :got, :back]
h = Hello.new
# => #<Hello:0x00000100a1b3b8
# @baby=3,
# @baby_with_history=[1, 2, 3],
# @got="the best",
# @got_with_history=["today", "is", "the best"]>
h.baby = 1
# => 1
h.baby = 2
# => 2
h.baby = 3
# => 3
h.baby
# => 3
h.baby_with_history
# => [1, 2, 3]
h.got = "today"
# => "today"
h.got = "is"
# => "is"
h.got = "the best"
# => "the best"
h.got
# => "the best"
h.got_with_history
# => ["today", "is", "the best"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment