Last Updated: February 25, 2016
·
148
· 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!