Created
February 16, 2012 17:35
-
-
Save chrishunt/1846639 to your computer and use it in GitHub Desktop.
attr_reader amend
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 Basket | |
attr_reader :contents | |
def initialize | |
@contents = [] | |
end | |
end |
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
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