Sha256: 2e270c11863e37d52838bb78478ab7b1590bc2165e1c2478c8be332682b41a94

Contents?: true

Size: 483 Bytes

Versions: 8

Compression:

Stored size: 483 Bytes

Contents

class Integer

  # Syntactic sugar to yield n times to a block.
  #
  # Return an array of any results.
  #
  # ==Example
  #   3.maps{rand} => [0.0248131784304143, 0.814666170190905, 0.15812816258206]
  #
  # ==Parallel 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.
  
  def maps
    (0...self).map{|i| yield i}
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
webget_ramp-1.7.1.8 lib/webget_ramp/integer.rb
webget_ramp-1.7.1.7 lib/webget_ramp/integer.rb
webget_ramp-1.7.1.6 lib/webget_ramp/integer.rb
webget_ramp-1.7.1.5 lib/webget_ramp/integer.rb
webget_ramp-1.7.1.4 lib/webget_ramp/integer.rb
webget_ramp-1.7.1.3 lib/webget_ramp/integer.rb
webget_ramp-1.7.1.2 lib/webget_ramp/integer.rb
webget_ramp-1.7.1.1 lib/webget_ramp/integer.rb