Sha256: 3fa4e86f59a45b15d1a05ed58f10bd0533b661e0343692153d9bb28db111d0a3

Contents?: true

Size: 343 Bytes

Versions: 47

Compression:

Stored size: 343 Bytes

Contents

unless Array.method_defined? :cycle
  require 'backports/tools/arguments'

  class Array
    def cycle(n = nil)
      return to_enum(:cycle, n) unless block_given?
      if n.nil?
        each{|e| yield e } until false
      else
        n = Backports.coerce_to_int(n)
        n.times{each{|e| yield e }}
      end
      nil
    end
  end
end

Version data entries

47 entries across 47 versions & 4 rubygems

Version Path
backports-3.6.7 lib/backports/1.8.7/array/cycle.rb
backports-3.6.6 lib/backports/1.8.7/array/cycle.rb
backports-3.6.5 lib/backports/1.8.7/array/cycle.rb
backports-3.6.4 lib/backports/1.8.7/array/cycle.rb
backports-3.6.3 lib/backports/1.8.7/array/cycle.rb
backports-3.6.2 lib/backports/1.8.7/array/cycle.rb
backports-3.6.1 lib/backports/1.8.7/array/cycle.rb