O'Reilly logo

Mastering Ruby Closures by Benjamin Tan Wei Hao

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Test Your Understanding!

  1. Implement the lazy version of Enumerable#select.

    Enumerable#select takes in a block containing a predicate. If the predicate evaluates to true, the element is emitted.

  2. Implement the lazy version of Enumerable#drop.

    drop takes in a single integer argument n. It drops the first n elements of the array and returns the rest. Note that since it is lazy, the rest of the enumerable still has to be constrained via first(n) or take(n).to_a.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required