Skip to content

Instantly share code, notes, and snippets.

@ananfang
Created July 27, 2012 04:43
Show Gist options
  • Save ananfang/3186216 to your computer and use it in GitHub Desktop.
Save ananfang/3186216 to your computer and use it in GitHub Desktop.
The yield statement: Definition
def do_twice
puts 'Start'
yield
yield
puts 'End'
end
do_twice { puts 'Hello world!' }
# Results:
#
# Start
# Hello world!
# Hello world!
# End
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment