Hiding warnings

M

Mark Somerville

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
 
X

Xavier Noria

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]
 
M

Mark Somerville

Spot on, thanks Xavier.

Mark

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]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,812
Messages
2,569,694
Members
45,478
Latest member
dontilydondon

Latest Threads

Top