In Ruby, the default setter is a lvalue-able form of the getter and is defined with the name "foo=()". They are generally named after the attribute. So, attribute foo would have a getter of
val = obj.foo and a setter of
obj.foo = newval. You can do
val2 = obj.foo = newval and both val2 and obj.foo have newval as a value. So, Ruby would follow #2.
My criteria for good software:
- Does it work?
- Can someone else come in, make a change, and be reasonably certain no bugs were introduced?