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!
Written by Dinesh Vasudevan
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Related Tags
#ruby
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#