what is the use of Lambda in Ruby??

Hi Guys,

i am learning ruby on rails and i am little bit confuse about the use of Lambda.

can anybody help me to understand the use of Lambda?

The short version is, it's a way to make an object out of a method-like chunk of code (including making it take parameters if you want), so that you can treat it like any other object. You can store it, copy it, pass it around as a parameter to methods, and execute it later, possibly many times and with different parameters.

For instance, I recently made a class whose initializer takes a lambda. Later, when you call certain methods on the objects of this class, they call the lambda. If you want to see how that works, and some examples of its usage, see https://github.com/davearonson/hook_lying_syncer -- though the actual purpose is to support Ruby "metaprogramming", which is a somewhat advanced technique.

-Dave