class Person def get_age @age end def set_age age @age = age end endshould be refactored to:
class Person def age @age end def age= age @age = age end endApart from using attr_accessor in those simple cases, it allows to send a more meaningful message:
person = Person.new person.age = 30 person.age
Supported by Ruby 2.1.1
Keine Kommentare:
Kommentar veröffentlichen