def with_current_time yield Time.now end with_current_time do |now| puts now.to_s end with_current_time do puts 'Hi' end with_current_time do |now, hogehoge| puts hogehoge.inspect end def default_argument_for_block yield end default_argument_for_block do |val = 'Hi'| puts val end def flexible_arguments_for_block yield 1, 2, 3 end flexible_arguments_for_block do |*params| puts params.inspect end def block_sample(&block) puts 'stand up' block.call if block puts 'sit down' end block_sample do puts 'hoge' puts 'fuga' end block_sample