June 2017
Beginner
330 pages
7h 30m
English
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.
Read now
Unlock full access