Aldric Giacomoni wrote:

> I don't understand what Ruby is doing / what happens.
> First question: the "name" variable is defined inside the method
> proc_with_enclosing_scope, so why would changing the name outside the
> method make a difference in the first place?

it doesn't make a difference, it still prints 'Ruby"


> And lastly.. I know that "proc" exists, too. What is the difference /
> what does it do?


Objects created with lambda don't affect the flow of the application outside of 
the block when returning a value; Proc objects created with Proc.new, on the 
other hand, will exit their enclosing method when returning.

def procnew
    new_proc = Proc.new { return "I got here..." }
    new_proc.call
    return "...but not here."
end

def lambdaproc
    new_proc = lambda { return "You get here..." }
    new_proc.call
    return "And I got here!"
end


Output
======
puts lambdaproc
=> And I got here!

puts procnew
=> I got here...

> 
> I thank you very much in advance for the enlightenment you will provide
> :)


-- 
Kind Regards,
Rajinder Yadav

http://DevMentor.org

Do Good! - Share Freely, Enrich and Empower people to Transform their lives.