- Continue to practice using
yield
and blocks. - Gain a deeper understanding of the common enumerable
.select
.
Now that we've built our own .each
and .collect
methods, let's build our own .select
method! If you don't remember what .select
does, review the Ruby docs on it.
Run bundle install
first to update or install any gems.
Write your code in lib/my_select.rb
. Get the tests to pass.
A few things to think about:
- What is the return value of yielding a character to a block?
- How can you ensure your
.select
method can respond appropriately to being passed an argument of an empty collection?
- All About Ruby - Ruby Blocks
- About.com - Block Parameters and Yielding
- Coda Hale's Blog - Writing a Method that Uses Code Blocks
- Reactive's Tips - Understanding Ruby Blocks, Procs, and Lambdas
View my_select on Learn.co and start learning to code for free.