Return to Snippet

Revision: 5516
at March 13, 2008 03:27 by cczona

Initial Code
def silently(&block)
  warn_level = $VERBOSE
  $VERBOSE = nil
  result =
  $VERBOSE = warn_level

# e.g.
silently { require 'net/https' }

Initial URL

Initial Description
You can turn off warnings for a section of your code by setting $VERBOSE to nil. Even better is to codify this in a method.  Since this method takes a block as its parameter, you can now pass it arbitrary chunks of code to execute without warnings.

Initial Title
Execute arbitrary code with different level of error messaging

Initial Tags

Initial Language