Ruby Blocks & Iterators
Design powerful, elegant Ruby code by mastering blocks and iterators in this example-driven course.
Blocks are an intrinsic and powerful aspect of the language. Many of the methods in the Ruby standard library assume you have a solid understanding of blocks. And blocks are used pervasively in Ruby gems (including Ruby on Rails) and all well-designed Ruby code.
In this hands-on video course, you'll learn blocks and iterators by example with over 40 real-world examples!
“I've been using Ruby for a few years and bumped into blocks but I was never really getting them. Your course helped me finally wrap my head around them! Now I'm off to refactor some of my code!” Hans verschooten
“This course taught me a number of great techniques… Even more valuable are the use cases, which set the course apart from many other programs that teach the how, but not the why.” Randy Burgess
Learn By Example and Exercise
Explore blocks used in 40+ real-world examples.
Block Basics
To be an effective Ruby programmer, you need to be very proficient with blocks. We'll start with the basics and work up to advanced block usage. In the end you'll be able to read and write any code that uses blocks.
When, Why, and How to Use Blocks
Once you're comfortable with the syntax, the next level is to understand when and why to use blocks. And the best way to do that is by looking at lots of good examples. You'll learn how to effectively apply blocks in a variety of situations to make your code more expressive, concise, and flexible.
Master the Enumerable Module
The methods in the Enumerable module—select, reject, map, reduce, and friends—are particularly great examples of the power of blocks. And once you grasp blocks, the secret to all these methods is suddenly revealed. Master the Enumerable methods and you'll be a more efficient Ruby programmer!
Custom Iterators
Ruby's built-in iterator methods—each, times, and so on— aren't "magical" once you understand how to yield to a block. Learn how to design your own classes and APIs using custom iterators like the ones you use every day.
Design Techniques & Patterns
Blocks offer a different (powerful!) style of programming that should influence the design of your code. Throughout the course we'll examine many use cases where blocks elegantly solve common problems. Discover how to use blocks to remove unnecessary code, manage resources, and more! You'll be able to immediately apply these techniques and patterns to your own code.
Real-World, Practical Examples
No dry definitions or boring theory here. This course is loaded with good examples of blocks and iterators used in various scenarios. By seeing recurring patterns in different contexts, you'll come away with a clear understanding of not just how blocks work but, equally important, when and where to use them.
What You'll Get
Lifetime access to everything you need!
“I really thought I had a good grasp on Ruby blocks, but I was mistaken. I am NOW quite confident about my understanding of blocks, and mastery over them. I suddenly feel newly empowered!”
Thom Parkin
Get started today!
No monthly subscription or time limit. You own it for life.
Questions? Email Mike and Nicole.
There's no risk. This course is 100% guaranteed for an entire 30 days. If you find it's not a good fit for you, we'll be happy to refund your money.
Live in a country where our courses aren't affordable? We offer purchasing power parity discounts.
For Beginner To Intermediate Ruby Programmers
Quickly transform into an empowered Ruby programmer!
Does using blocks feel mysterious?
In this course we walk through over 40 code examples that illustrate how blocks work so you can use them with more confidence.
Ready to level up?
With a deeper understanding of the when, how, and why of blocks, you'll be well on your way to mastering Ruby.
Want to design your code the Ruby way?
You'll learn design techniques, patterns, and idioms that you can then apply to your own code.
New to Ruby?
If you're brand new to the Ruby programming language we strongly recommend taking our Ruby course before taking this course.
Created with 💛 by
Mike and Nicole Clark
Howdy! We're the friendly couple behind The Pragmatic Studio.
We've been making courses for developers since 2012. It's a privilege to get to teach together and serve everyone who supports us.
We made this course because blocks and iterators are knitted into the very fabric of Ruby. Once you've mastered them, you've mastered Ruby. This is the course we desperately needed in our early days of Ruby (nearly 20 years ago!). We could have benefited from lots of examples, and so this course delivers exactly that. We hope you enjoy it!
This course has helped thousands!
Here's what some of them have to say…
“This course, as well as all the other Pragmatic Studio courses, approaches perfection! The tone is pleasant, the explanations are clear, the exercises are interesting, and the course is ideal for practicing and learning.” Bruno Dusausoy
“I highly recommend this for anyone, not just those who want to learn Ruby, but also to those who want to learn good software design in general.” Elliot Kleiman
“I have a much better understanding and can confidently implement blocks using yield. Also, the Execute Around pattern you teach is magnificent, and since finishing the class I'm writing methods with fresh eyes!” Dan Wagner
“What an awesome course! I've taken your Ruby and Rails courses and I've been writing Rails apps for a few years now, so I came to the course thinking that I had a pretty good grasp of blocks. I hoped to simply learn some subtleties and details that I had missed. By the end of the course, I had a completely new and better understanding of blocks and iterators and more importantly, how I could make my code better. You guys are natural teachers, so watching the videos is as fun as doing the exercises. You've helped me to be a better coder! I can't wait until the next course!” Wayne Hiner
“I've been using Ruby for a few years and bumped into blocks but I was never really getting them. Your course helped me finally wrap my head around them! Now I'm off to refactor some of my code!” Hans verschooten
“I liked the hands-on style, the spiral-learning approach, and the real-world application. More than anything, the use cases at the end helped reinforce the concepts from the first part of the course and were very helpful in understanding good, eloquent, expressive design in Ruby code. I loved it!.” Ryan Benedetti
“The use cases gave me ideas on how to refactor the code in my own Ruby program. The Execute Around use case paradigm has significantly cleaned up my code already.” Kevin Allen
“I'd read about Ruby blocks before, but nothing really clicked until I worked through this course. Thanks for a great course!” Tom Belunis
“This is my fourth Pragmatic Studio online course and I've loved all of them. My Ruby and Rails skills are clearly more honed and I am feeling ready to tackle whatever projects come my way. I am very much looking forward to future courses when they are available. They are worth every penny and well worth the time spent.” Bob Fried
“I've played around with Ruby for many years now but never took the time to properly understand blocks and iterators the way I should have. This was a very accessible course that I found quite enjoyable. I can apply much of what I've learned to my current Ruby projects.” Sam Marten
“Thank you for putting together another awesome course! I have tried following along with books, but feel that I have gotten much more out of the videos and exercises in your courses. Being able to code along with the videos and then apply what I learned to the exercises helped me a lot!” Curtis Browning
“I really thought I had a good grasp on Ruby blocks, but I was mistaken. I am NOW quite confident about my understanding of blocks, and mastery over them. I suddenly feel newly empowered!” Thom Parkin
“I really liked the step-by-step explanations about how blocks work and how the internal methods are implemented. Also, super explanatory animations!” Haris Dimitriou
“I loved the real-life examples, rather than contrived code, in this course. These examples made it easy to relate the techniques to my own code.” Steve Willis
“I never had the time to sit down and understand Ruby blocks, despite seeing them used frequently in Rails apps. This course taught me a number of great techniques, utilizing both iterators and blocks, that I probably wouldn't have learned on my own. Even more valuable are the use cases, which set the course apart from many other programs that teach the how, but not the why. Finally, the examples and code animations do a great job explaining how things work at a pace that's easier to process.” Randy Burgess
“I got my first dev job mostly because of a lot of hard work paired with Mike and Nicole's Ruby and Rails courses. I'm getting close to 8 months in as a full-time programmer and this course was perfect for me. I can't wait to go back and use these design patterns to refactor the code I've produced! Y'all are a real 'gem' in the Ruby community.” Hunter Stewart
“I've read countless blogs, and watched many other videos to try and understand blocks, but they all seem to either be filled with assumptions or never provide any depth to their explanations. I always found myself with no greater understanding than when I started. This course was just what I needed to break free from my fear and avoidance of Ruby blocks. It provided meaningful explanations and the right balance of exercises to help me lock in my newfound understand of blocks.” Lee Stetson
“The real-world examples in this course really demonstrated each concept and helped me cement the ideas you presented. I've watched other Ruby and Rails videos and I think your lesson structures and attention to detail makes your courses some of the best on the Internet. Thank you!” Clinton De Young
“This course was really enlightening for me! It showed me new ways of thinking and approaching problems. I'd seen these patterns in Ruby code quite a bit but never really understood exactly what was happening. This course pulled back the curtain and helped me see how things work. I can already think of areas where I can apply these concepts to my own projects. Thanks!” Tom Harrison
“It's easy to get accustomed to this beautiful language of Ruby but getting a peek at the innards really solidifies my understanding of it. This course has given me the confidence to go below the surface because it isn't always as scary as it seems. Understanding Ruby blocks and iterators were a big part of that, so thank you so much for developing this course.” Jay Loung