Saw this on another page:
"with getter, one obtains the current value of @a, without modifying it."
"with setter, one modifies @a, and get its new value as return value."
However, looking at this code from the cancan wiki, I see that both the setter and the getter are actually doing something to the variable in it.
def roles=(roles)
self.roles_mask = (roles & ROLES).map { |r| 2**ROLES.index(r) }.inject(0, :+)
end
def roles
ROLES.reject do |r|
((roles_mask || 0) & 2**ROLES.index(r)).zero?
end
end
It looks like the getter is actually returning a truth value, and if not that, at least some sort of transformation. So is this "getters get without modifying, setters set with modifications" rule actually true?