0026 Lazy

Take a break!

The Enumerable module defines the lazy method that will transform your iterators into streams. In addition to being able to handle infinite Ranges more easily, it will be able to perform more efficiently.

0026-lazy_1.png

It works by changing the order of execution. Instead of proceeding « by method « , it proceeds « by element « , avoiding unnecessary operations whenever possible.

0026-lazy_2.png 0026-lazy_3.png

The eager method transforms back into a classic iterator (without losing the advantages defined so far) to be transparent if necessary.

0026-lazy_4.png

Link to Ruby documentation for lazy.