Class: Integer
Overview
Integer extensions
Instance Method Summary collapse
-
#maps ⇒ Object
Syntactic sugar to yield n times to a block.
Instance Method Details
#maps ⇒ Object
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.
20 21 22 |
# File 'lib/webget_ruby_ramp/integer.rb', line 20 def maps return (0...self).map{|item| yield item} end |