Skip to content

Instantly share code, notes, and snippets.

@rauchy
Created November 20, 2012 10:27
Show Gist options
  • Save rauchy/4117153 to your computer and use it in GitHub Desktop.
Save rauchy/4117153 to your computer and use it in GitHub Desktop.
Blocks In-depth: Calling Blocks
def log
if block_given?
puts "before block"
yield
puts "after block"
end
end
log # nothing will be displayed!
def log
puts "before block"
yield
puts "after block"
end
log do
puts "o hai"
end
some_method(some_argument) do
# block content goes here
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment