What is attr_accessor in Ruby?

196
I am having a hard time understanding attr_accessors in Ruby, can someone explain them to me? I have done tons of Google searches, just can't understand them fully.
asked
6 answers
542
Let's say you have a class Person. class Person end person = Person.new person.name # => no method error Obviously we never defined method name. Let's do that.
answered
39
attr_accesssor is just a method. (The link should provide more insight with how it works - look at the pairs of methods generated, and a tutorial should show you how to use it.)
answered