Code Editor
Blocks, Procs, and Lambdas

Now You Try!

Great work! You've written your own lambda and seen how to pass it to a method. Now it's time for you to write a lambda and pass it to a method!

If you think this will be a lot like what you've already done with procs, you're exactly right. Just like with procs, we'll need to put & at the beginning of our lambda name when we pass it to the method, since this will convert the lambda into the block the method expects.

That symbolize lambda was pretty cool. Let's riff on it with a lambda that checks to see if each element in an array is a symbol. We can do this checking with the .is_a? method, which returns true if an object is the type of object named and false otherwise:

:hello.is_a? Symbol # ==> true

The word Symbol has to be capitalized when you're doing an .is_a? check!

Community Forums
Get help and ask questions in the Codecademy Forums
Report a Bug
If you see a bug or any other issue with this page, please report it here.