Skip to content

Instantly share code, notes, and snippets.

@chrishunt
Created February 16, 2012 17:35
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 chrishunt/1846639 to your computer and use it in GitHub Desktop.
Save chrishunt/1846639 to your computer and use it in GitHub Desktop.
attr_reader amend
class Basket
attr_reader :contents
def initialize
@contents = []
end
end
basket = Basket.new
#=> #<Basket:0x007f8f92aaf9f0 @contents=[]>
basket.contents
#=> []
basket.contents = [:flower]
# NoMethodError: undefined method `contents=' for #<Basket:0x007f8f92aaf9f0>
basket.contents << :flower
#=> [:flower]
basket.contents
#=> [:flower]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment