Sha256: 20d37bfde002cc84c71d245dfe2daa98639fbb4d4cfba61a966529f7ff4b4ce5

Contents?: true

Size: 295 Bytes

Versions: 4

Compression:

Stored size: 295 Bytes

Contents

class Integer
  # Like #times but returns a collection of the yield results.
  #
  #   require 'facet/integer/times_collect'
  #
  #   a = 3.times_collect { |i| "#{i+1}" }
  #   a => [ "1", "2", "3" ]
  #
  def times_collect(&yld)
    a = []; self.times{ |i| a << yld.call(i) }
    a
  end
end 

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
facets-0.6.3 lib/facet/integer/times_collect.rb
facets-0.7.0 lib/facet/integer/times_collect.rb
facets-0.7.1 lib/facet/integer/times_collect.rb
facets-0.7.2 lib/facet/integer/times_collect.rb