CSC/ECE 517 Fall 2012/ch2a 2w26 aj
SaaS 4.6 Enhancing Rotten Potatoes again
Introduction
This article aims to explore the closure implementations, primarily in Ruby and also in other dynamic scripting languages like C#, JavaScript, Perl and Python. At the end of this article, we intend to present a comparison in the implementations of closures in all the languages, since each language handles it differently. The comparison is provided only to show how the closures are implemented. The article is not intended to be a reference guide for closures, but more like a quick start guide to understanding closures. References and additional learning resources are provided for the reader to go and explore the world of closures in much more detail
Code Blocks
Before understanding the concept of Closures, let us take a brief introduction on “Code Blocks” in Ruby. A code block is a chunk of code, Ruby statements and expressions written between curly braces { } or between “do…end”. For example: