Why do we need attr_accessor?
<p>I fail to understand why we needed the attr_reader and attr_writer, or attr_accessor to be declared in a class. I read both <a href="https://stackoverflow.com/questions/4370960/what-is-attr-accessor-in-ruby">this</a> and <a href="https://stackoverflow.com/questions/5046831/why-use-rubys-attr-accessor-attr-reader-and-attr-writer">this</a> posts, but those posts explain mainly how they work, not as much as why they are there. </p>

<p>In case of </p>

<pre><code>class Person
  attr_accessor :age
end

bob = Person.new
bob.age = 99
bob.age
</code></pre>

<p>It seems a little redundant having to tell Ruby to write and read age, while not being able to write and read instance variable outside the class automatically. Why do we need to set up reader and writer in the Class instead of the following code and save a few lines?</p>

<pre><code>class Person
end

bob = Person.new
bob.age = 99
bob.age 
</code></pre>