class Curious
def calculation
def calculation
@retrieved_value
end
@retrieved_value = #some kind of intensive process
end
end
Doing the above, the outer method will be run the first time and the inner method will provide the value subsequent times. What’s the advantage or disadvantage of doing that over a single non-nested method that just does @retrieved_value ||= #some kind of intensive process?
You’re redefining the
calculationmethod for theCuriousclass. This will affect other instances: