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.25.0 lib/backports/1.8.7/array/cycle.rb
backports-3.24.1 lib/backports/1.8.7/array/cycle.rb
backports-3.24.0 lib/backports/1.8.7/array/cycle.rb
backports-3.23.0 lib/backports/1.8.7/array/cycle.rb
backports-3.22.1 lib/backports/1.8.7/array/cycle.rb
backports-3.22.0 lib/backports/1.8.7/array/cycle.rb
backports-3.21.0 lib/backports/1.8.7/array/cycle.rb
backports-3.20.2 lib/backports/1.8.7/array/cycle.rb
backports-3.20.1 lib/backports/1.8.7/array/cycle.rb
backports-3.20.0 lib/backports/1.8.7/array/cycle.rb
backports-3.19.0 lib/backports/1.8.7/array/cycle.rb
backports-3.18.2 lib/backports/1.8.7/array/cycle.rb
backports-3.18.1 lib/backports/1.8.7/array/cycle.rb
backports-3.18.0 lib/backports/1.8.7/array/cycle.rb
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/backports-3.12.0/lib/backports/1.8.7/array/cycle.rb
backports-3.17.2 lib/backports/1.8.7/array/cycle.rb
backports-3.17.1 lib/backports/1.8.7/array/cycle.rb
backports-3.17.0 lib/backports/1.8.7/array/cycle.rb
backports-3.16.1 lib/backports/1.8.7/array/cycle.rb
backports-3.16.0 lib/backports/1.8.7/array/cycle.rb