Fearless Fool wrote in post #988575:
> This isn't a question -- it's just a comment that I find it awesome and
> only slightly mysterious that a lambda can reference the variable it is
> assigned to in its body, such as p here:
>
>>> p = lambda {|n| puts "bing #{n}" ; p.call(n-1) if n > 0 }
>>> p.call(5)
> bing 5
> bing 4
> bing 3
> bing 2
> bing 1
> bing 0
> => nil
>
> I guess that's the power of a real lexical closure.  Very handy.

For a real eye-opener, see this discussion from 2007.
https://groups.google.com/d/topic/comp.lang.ruby/OlHsBJoud_0/discussion

-- 
Posted via http://www.ruby-forum.com/.