jdm wrote:
> i'm trying to create what C calls a static local variable inside a particular
> method, i.e. this variable should not be visible outside the method and its
> value should survive the activation of the method.
> 
> instance variables are "static" but visible to all methods of the instance.
> 
> local variables are visible only to a particular method but aren't "static".
> 
> i've been through the pickaxe book and nothing obvious popped out at me. it
> seems i could synthesize the desired functionality using singleton methods
> attached to a particular instance (or maybe by defining a block within the
> method) but i'm hoping there's a simpler, cleaner way.
> 
> thanx in advance.

I would recommend just creating an object of some sort but if you really
need to, you can use instance variables of the enclosing scope (even the
top-level).

def foo(x)
   # Use the existing one if any or initialize
   @__foo_var ||= initializer
   do_something_with x, @__foo_var
end


E
-- 
No-one expects the Solaris POSIX implementation!