Last active
December 21, 2015 19:49
-
-
Save maletor/6356577 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Integer | |
# Public: Return n number of somthing as Array. | |
# | |
# Examples | |
# | |
# foot = 5.of { Toe.new } # => [<toe>, <toe>, <toe>, <toe>, <toe>] | |
# feet = Array.new(5) { Toe.new } # => [<toe>, <toe>, <toe>, <toe>, <toe>] | |
# | |
def of | |
(0..self-1).map { |n| yield n } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment