From: Michael Neumann Date: 2004-08-04T04:21:12+09:00 Subject: Re: Closure question Fitzgerald,Greg wrote: > I'm trying to make a function act as a counter, but I can't seem to get > it to work. Here's what I've tried: > > def count > counter = 1 > def count > proc {counter += 1}.call > end > counter > end def create_count counter = 0 return proc { counter += 1 } end counter = create_count counter.call # => 1 counter.call # => 2 counter.call # => 3 Regards, Michael