What is attr_accessor in Ruby?
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.
Let's say you have a class Person.
person = Person.new
person.name # => no method error
Obviously we never defined method name. Let's do that.
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.)