Ruby closure scope and other ideas

In Ruby you can have closures with a Block, a Proc or a Lambda. They are very similar and have subtle differences.
I've found this article very clear to me: Understanding Ruby Blocks, Procs and Lambdas

In short, for what I understood, Blocks cannot have parameters and ( ) cannot be stored while Procs can like Lambdas.
Blocks cannot execute a return statement, Procs can and the calling method will return, Lambdas can too and simply return the value to the calling method.

Here are the scope examples

For me this has been the year of Social Complexity, C# 4.0, some Functional programming and testing, JavaScript, Ajax, Smalltalk and now Ruby.
For the new year I see coming Sinatra, Mac, Linux, Lean-Startup, more Agile Coaching, Mentoring and more management.
Let's see what it comes

See also: JavaScript: closure scope  and other ideas

Print | posted @ sabato 31 dicembre 2011 08:40

Comments have been closed on this topic.