Created
November 27, 2015 11:14
-
-
Save alcy/9a2da91b4b5fb240aec1 to your computer and use it in GitHub Desktop.
times implementation using each operator
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 | |
def my_each(size) | |
c = 0 | |
until c == size | |
yield(c) | |
c += 1 | |
end | |
end | |
def my_times | |
my_each(self) { |a| yield a } | |
end | |
end | |
5.my_times { |i| puts i } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment