Infinitely iterate through an array in Ruby.
by Rabbit
class Array def roll loop { each { |e| yield(e) } } end end
>> a = [ 'a', 'b', 'c' ]
=> ["a", "b", "c"]
>> a.roll { |e| puts e; sleep 1 }
a
b
c
a
b
c
a
...
class Array def roll loop { each { |e| yield(e) } } end end
>> a = [ 'a', 'b', 'c' ]
=> ["a", "b", "c"]
>> a.roll { |e| puts e; sleep 1 }
a
b
c
a
b
c
a
...
I don't believe in "intellectual property". If you do, consider rabbitcreative.com as licensed under a Creative Commons Attribution 3.0 License.