Skip to content

Instantly share code, notes, and snippets.

@alcy
Created November 27, 2015 11:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alcy/9a2da91b4b5fb240aec1 to your computer and use it in GitHub Desktop.
Save alcy/9a2da91b4b5fb240aec1 to your computer and use it in GitHub Desktop.
times implementation using each operator
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