small medium large xlarge

Mastering Ruby Closures: A Guide to Blocks, Procs, and Lambdas

August 09, 2017

Blocks, procs, and lambdas, oh my! If you've used Ruby, you've seen these constructs, and maybe even used them. Learn how to fully use these elegant tools with Mastering Ruby Closures, now available in print and ebook from

Last week we announced that the hugely popular A Common-Sense Guide to Data Structures and Algorithms was in print and shipping, however, due to a small data hiccup, it wasn't actually available for you to order in print last week! We've fixed that, and you can now order the print edition for your collection from

Come and get it today!


Mastering Ruby Closures: A Guide to Blocks, Procs, and Lambdas

Ruby developers use the Ruby language as the yardstick for expressivity, flexibility, and elegance—and a large part of this is due to blocks, lambdas, and procs. These language features make Ruby one of the most beautiful and pleasant languages to work with. Learn how to understand and craft code that will take you closer to Ruby mastery.

Start with the basics of closures and then dive into blocks, as you learn about the patterns that involve blocks, and how they are used in real-world code. Then create and use procs and lambdas. Finally, build your own lazy enumerables with advanced Ruby features such as fibers and generators. Along the way, work with computer science concepts such as closures, free variables and first-class functions. Spot a closure easily. Identify the patterns where you can effectively use blocks and re-implement common standard library methods using them. Trace through how Symbol#to_proc works and find out the different ways of calling procs. This succinct guide takes you through the different kinds of Ruby closures with engaging examples, and each chapter comes with exercises that test and challenge your understanding.

When you finish this book, blocks, procs, and lambdas will have become an integral part of your Ruby toolbox.

Now available in print and ebook from

Upcoming Author Appearances

  • 2017-08-13 Jeff Kelley, 360|iDev, Denver, CO
  • 2017-08-13 Janie Clayton, 360iDev, Denver, CO
  • 2017-08-28 VM Brasseur, /dev/world/2017
  • 2017-09-11 Johanna Rothman, Agile Prague
  • 2017-09-11 Johanna Rothman, Agile Prague
  • 2017-09-11 VM Brasseur, Linux Foundation Open Source Summit North America 2017
  • 2017-09-22 Rachel Davies, Agile Greece Summit, Athens
  • 2017-09-28 Alex Miller, Strange Loop, St. Louis, MO
  • 2017-10-01 VM Brasseur, Velocity NYC
  • 2017-10-05 Rachel Davies, Software Craftsmanship, London
  • 2017-10-06 VM Brasseur, SeaGL 2017
  • 2017-10-09 Ian Dees, Pacific Northwest Software Quality Conference (PNSQC), Portland, OR
  • Did You Know?

    You can synch your ebooks among your devices via Dropbox, including updates! Just login to your account on, edit your profile, and connect your Dropbox account. See our FAQ for details.

    Don't Get Left Out

    Are your friends jealous that you get these spiffy email newsletters and they don't? Clue them in that all they need to do is create an account on (email address and password is all it takes) and select the checkbox to receive newsletters.

    Are you following us on Twitter and/or Facebook? Here's where you can find us and keep up with the latest news and commentary, and occasional discounts:

    Tell your friends! Tweet this

    Follow us on Twitter: @pragprog, @pragpub, Andy Hunt @PragmaticAndy.

    Coming Soon:

    • Learn Functional Programming with Elixir: New Foundations for a New World
    • Release It! Second Edition: Design and Deploy Production-Ready Software
    • React for Real (exPress)
    • Craft GraphQL APIs in Elixir with Absinthe

    Recently Released:

    Thanks for your continued support,

    Andy Hunt Publisher, Pragmatic Bookshelf

    Books • eBooks • PragPub Magazine • Audiobooks and Screencasts