Skip to content

Instantly share code, notes, and snippets.

@otobrglez
Created November 16, 2011 12:31
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 otobrglez/1369969 to your computer and use it in GitHub Desktop.
Save otobrglez/1369969 to your computer and use it in GitHub Desktop.
Just playing with blocks...
# Playing with blocks :)
class Integer
def times(&block)
(0...self).each do |i|
block.call i
end
end
end
# How to use...
3.times do |i|
puts "Hello world! #{i}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment