Yield



examples/functions/yield.cr
def run
  puts "before"
  yield
  puts "after"
end

run {
  puts "in block"
}

run do
  puts "in do-end"
end

examples/functions/yield_block.cr
def run(&block)
  puts "before"
  yield
  puts "after"
end

run {
  puts "in block"
}

examples/functions/twice.cr
def run
  puts "before"
  yield
  puts "middle"
  yield
  puts "after"
end

run {
  puts "in block"
}
puts "----"
run do
  puts "in do-end"
end