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?

On Sun, Dec 14, 2014 at 10:40 AM, Jitendra Sharma
[email protected] wrote:

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
GitHub - davearonson/hook_lying_syncer: Ruby gem to keep method_missing and respond_to_missing? in sync – though the actual
purpose is to support Ruby “metaprogramming”, which is a somewhat
advanced technique.

-Dave


Dave A., consulting software developer of Codosaur.us,
PullRequestRoulette.com, Blog.Codosaur.us, and Dare2XL.com.