File: logging.rb

Project: Invitation to Ruby

#!/usr/bin/env ruby

def when_logging
  yield if $do_logging
end

$do_logging = false
when_logging { puts "Never Printed" }

$do_logging = true
when_logging { puts "Always Printed" }


[ Index ][ Table of Contents ]
Generated by [ source2html ]