1: #!/usr/bin/env ruby 2: 3: def when_logging 4: yield if $do_logging 5: end 6: 7: $do_logging = false 8: when_logging { puts "Never Printed" } 9: 10: $do_logging = true 11: when_logging { puts "Always Printed" }
Always Printed