From: Joel VanderWerf [mailto:[email protected]]
Joel VanderWerf wrote:
Use closures and class scopes:
tmp1 = ExpensiveObject.new
tmp2 = ExpensiveObject.new
Assuming you want to share the tmp1 and tmp2 among all instances of the
class, which probably you don’t want. Sorry.
No, I very much do - each object is only needed as a ‘scratch’ pad for
performing calculations within the method; before and after the method I
don’t care about the value. Your idea has interesting merit. I hadn’t
thought of closing and re-opening the class to ‘reset’ the closure
scope. Or (for that matter) of using define_method to create a method as
a closure as both you and David suggested.
Thanks, interesting ideas!