Ruby 1.9.2 リファレンスマニュアル > ライブラリ一覧 > 組み込みライブラリ > Enumerableモジュール > cycle
cycle -> Enumerator
cycle {|obj| ... } -> object | nil
Enumerable オブジェクトの要素を、繰り返し無限に生成し続けます。
Calls block for each element of enum repeatedly forever. Returns nil if and only if the collection is empty. Enumerable#cycle saves elements in an internal array so changes to enum after the first pass have no effect.
a = ["a", "b", "c"] a.cycle {|x| puts x } # print, a, b, c, a, b, c,.. forever.