Let's say I have a class called Person and person has an attribute called partner. When I call partner= on one of the Person objects, I want to set the @partner instance variable of both objects. Here's an example with invalid syntax:
class Person
attr_reader :partner
def partner=(person)
# reset the old partner instance variable if it exists
partner.@partner = nil if partner
# set the partner attributes
@partner = person
person.@partner = self
end
end