Last updated 7 months ago
Was this helpful?
Getters and setters are so frequently defined that they're part of the language.
attr_reader - adds a getter
attr_writer - adds a setter
attr_accessor - adds a getter and a settor
class Person attr_accessor :name # same goes for attr_reader and attr_writer end person = Person.new person.name = "Litsy" person.name # => "Litsy"