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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.165.62