Now that you’re comfortable with the basic style and syntax of Ruby blocks, you’re ready to use blocks to make your code more expressive, compact, and flexible. One way to do that is by using blocks to get the most out of the Ruby standard library. Indeed, many of Ruby’s most powerful methods take a block.
The methods in the Enumerable module—select, reject, map, reduce, and friends—are particularly great examples of the power of blocks. Master the Enumerable methods and you’ll be a more efficient Ruby programmer!
Start saving time and improving your code by checking out the video below from our Mastering Ruby Blocks & Iterators course. It’s part two of a two-part series on tapping into the Enumerable module.
And that’s just the warm-up. Once you start calling Ruby methods that take blocks, you’ll want to design your own methods that yield to blocks. That’s the focus for the remainder of the course. We explore various block design techniques and patterns that you can immediately apply to your own code. More about that on Monday…