by muchabi · 12y ago · 0 comments
class Car
attr_reader :model, :company # only read
attr_accessor :color # read and write
endThis is pretty trivial so bear with me... If you have something that looks like this...
class Person
attr_reader :children
def initialize
@children = []
end
end
You can then do this... x = Person.new
x << "Bobby"
You will have then altered the value of @children without completely reassigning it.