Hiding warnings


#1

I have a couple of sections of code that I don’t want any warnings
displayed
for. I’d still like the warnings for the rest of the application.

Can I turn warnings on and off programatically?

Mark


#2

On Feb 10, 2006, at 11:13, Mark S. wrote:

I have a couple of sections of code that I don’t want any warnings
displayed
for. I’d still like the warnings for the rest of the application.

Can I turn warnings on and off programatically?

Yes, the idiom is $VERBOSE = nil.

– fxn

% irb
irb(main):001:0> a = []
=> []
irb(main):002:0> a.push (0)
(irb):2: warning: don’t put space before argument parentheses
=> [0]
irb(main):003:0> current_W = $VERBOSE
=> false
irb(main):004:0> $VERBOSE = nil
=> nil
irb(main):005:0> a.push (0)
=> [0, 0]
irb(main):006:0> $VERBOSE = current_W
=> false
irb(main):007:0> a.push (0)
(irb):7: warning: don’t put space before argument parentheses
=> [0, 0, 0]


#3

Spot on, thanks Xavier.

Mark