def do_something(&block) puts "(1)" yield block puts "(2)" end def do_this puts "(3)" do_something do puts "(4)" next puts "(5)" end puts "(6)" end do_this outputs (3) (1) (4) (2) (6)