Class: Integer

Inherits:
Object show all
Defined in:
lib/webget_ramp/integer.rb

Instance Method Summary collapse

Instance Method Details

#mapsObject

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.



16
17
18
# File 'lib/webget_ramp/integer.rb', line 16

def maps
  (0...self).map{|i| yield i}
end