Cycle an array : cycle « Array « Ruby






Cycle an array


a = ['a','b','c']
a.cycle {|e| print e }             # Ruby 1.9: prints "abcabcabc..." forever

 

Related examples in the same category