Sha256: e3f16b9aa354b077ec3386d174248ffc01eeb551af0b9d7db340ff6b851a5511

Contents?: true

Size: 595 Bytes

Versions: 1

Compression:

Stored size: 595 Bytes

Contents

# -*- encoding: utf-8 -*-

# Integer extensions

class Integer

  # Syntactic sugar to yield n times to a block.
  #
  # Comparison to Integer#times: 
  # Integer#maps is similar to Integer#times except that the output from each
  # call to the block is captured in an array element and that array is
  # returned to the calling code.
  #
  # @return an array of any results
  #
  # @example Generate an array of three random numbers
  #   3.maps{rand}
  #   => [0.0248131784304143, 0.814666170190905, 0.15812816258206]
  #
  
  def maps
    return (0...self).map{|item| yield item}
  end


end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
webget_ruby_ramp-1.8.2 lib/webget_ruby_ramp/integer.rb