Fearless Fool wrote in post #988777:
> 7stud -- wrote in post #988636:
>> How do recursive methods grab you?
>> ...
>> You might want to ponder the difference between your example and a
>> recursive method.
>
> @7stud: Pardon if I wasn't clear in my OP, but I was asking about
> recursion.

My point was that a recursive method seems harder to explain than your 
lambda example.  As you detailed, your lambda example can be explained 
by a closure.

In the case of a recursive method, how do you explain being able to call 
a name that doesn't even exist yet?  Is it because what's really 
happening is something like this:

factorial = Method.new(Object) do
  if n == 1
     1
   else
     n * factorial(n-1)
   end
end

...and therefore a closure can explain why it works?  In ruby, you can 
certainly do something this:

MyClass = Class.new do
   def greet
     say 'hi'
   end
end

MyClass.new.greet

--output:--
hi

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