Last Updated: February 25, 2016
·
160
· dinks

Infinite collections in Ruby

Always use lazy!

(0..3).lazy.cycle.map {|x| x * 10}.take(5).to_a

Without lazy, the program wont stop!