Can someone give me the best possible solution for this,
I have a class
Class A
def a
return "a" if @logic
return "b"
end
def change_logic
@logic = true
end
end
In my solution, I should be able to do
object = A.new
object.change_logic
object.a #print "a"
or
object = A.new
object.a #print "b"
To implement this I created the method change_logic & it will change @logic instance variable.
But I need to implement this without having a instance variable like @logic
What will be the best way to do it??
@logic?@logic"? Is it enough to just rename the instance variable? Would a closure closing over a local variable count as "like an instance variable"? Would a class variable with a map from instances to values count as "like an instance variable"? Can you give a precise, unambiguous, objective, exact, complete specification of what exactly "like an instance variable" means?change_logicmethod to modifyareturn value? I can't imagine the reason behind that requirementdelegatesorattr_writer??