Click here to navigate the course.

Drag the edges to resize the window.

In Projects, you can keep track of your progress as you go throught the tasks. Check each item as you complete it!

Code Editor
Learn
Blocks, Procs, and Lambdas

Learning to Yield

Why do some methods accept a block and others don't? It's because methods that accept blocks have a way of transferring control from the calling method to the block and back again. We can build this into the methods we define by using the yield keyword.

Instructions

Check out the code in the editor. We've set up a series of puts statements so you can see when we're in the block_test method and when we're in the block passed to it. Click Run to see the result!

Report a Bug
If you see a bug or any other issue with this page, please report it here.