class Person
attr_accessor :name
def set_name
@name = 'joe'
end
def dump_by_varibale
puts @name
end
def dump_by_reader
puts name
end
end
a = Person.new
a.set_name
a.dump_by_varibale #=> "joe"
a.dump_by_reader #=> "joe"
puts a.name #=> "joe"
# set by writer
a.name = "john"
a.dump_by_varibale #=> "john"
a.dump_by_reader #=> "john"
puts a.name #=> "john"