From: Jim Freeze Date: 2002-07-30T21:48:38+09:00 Subject: Procs and scope (function pointers) Hi: I have a class that that has several procs (function pointers). I would like to keep these procs defined as class variables. Also, I wish the procs to be able to access member variables. However, I'm not sure this is possible. I did see some esoteric tricks by Matz in earlier postings but I did not know if they apply. Here is a sample of what I want to do: class Func F1 = proc { |x| x } F2 = proc { |x| x**2 } ... def initialize(func) case func when :F1 then @func = F1 when :F2 then @func = F2 ... raise "unknown" end def compute(x) @func.call(x) end end This works, but not if F? accesses an instance variable or method. If I move the proc definitions inside the initialization method, I can get the required binding I need and can call instance methods. Is there a way to access instance methods/variables and still keep the function definitions at the class level? Thanks -- Jim Freeze If only I had something clever to say for my comment... ~