Originally published at: http://www.sitepoint.com/closures-ruby/
What’s a Closure?
A closure is basically a function that:
- Can be treated like a variable, i.e. assigned to another variable, passed as a method aument, etc.
- Remembers the values of all the variables that were in scope when the function was defined and is able to access these variables even if it is executed in a different scope.
Put differently, a closure is a first-class function that has lexical scope.