8 Dec 2013
Lambdas are a powerful way to write anonymous functions (or closures) in Ruby. I wrote about the subtle differences between lambdas and procs here, and this post is about something a little different. I recently discovered a number of different ways to invoke lambdas that I had never seen before, and ended up learning something new about Ruby itself.
Let's look at a basic example. Here is a lambda that doesn't do much of anything:
test = lambda do |*args| p args end
So we have a lambda
test that prints its arguments when invoked. The most basic example of this would be something like: