Stabby lambdas

In real-world projects, it's a common practice to use a different syntax though: the stabby lambda. Here is how you can use stabby lambdas:

full_name = -> (first, last) { first + " " + last } 

If you run this code, it runs exactly the same way as the previous one.

Like procs, you can also run the lambdas with the call syntax:

p first_name.call("jordan", "hudgens") 

So, that's how you create lambdas in Ruby with both the regular and stabby syntaxes.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.48.181