Re-defining the method 'count' within its own scope won't really help;
you could do some sort of undef/def swap, but I think that's more
complexity than you really need.

To emulate an anonymous closure with no associated object instance in
Ruby, you need to use a 'proc' object bound in a context where your
counter variable is in scope.

For example:

---
def make_counter
  i = 0
  proc { i+=1 }
end

c = make_counter
c.call
 => 1
c[] # alias for '.call'
 => 2

d = make_counter
d[]
 => 1
---
Does that help?

Lennon