# Hiding warnings

**URL:** <https://www.ruby-forum.com/t/hiding-warnings/53579>\
**Category:** Ruby\
**Created:** [February 10, 2006, 11:13am UTC](https://www.ruby-forum.com/t/hiding-warnings/53579 "2006-02-10T11:13:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mslagell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e274bd/32.png) [@mslagell](https://www.ruby-forum.com/u/mslagell)\
**Post date:** [February 10, 2006, 11:13am UTC](https://www.ruby-forum.com/t/hiding-warnings/53579/1 "2006-02-10T11:13:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mslagell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e274bd/32.png) [@mslagell](https://www.ruby-forum.com/u/mslagell)\
**Post date:** [February 10, 2006, 11:27am UTC](https://www.ruby-forum.com/t/hiding-warnings/53579/2 "2006-02-10T11:27:02Z")

</div>

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]

---

<div class="post-metadata">

**Author:** ![mslagell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e274bd/32.png) [@mslagell](https://www.ruby-forum.com/u/mslagell)\
**Post date:** [February 10, 2006, 12:11pm UTC](https://www.ruby-forum.com/t/hiding-warnings/53579/3 "2006-02-10T12:11:46Z")

</div>

Spot on, thanks Xavier.

Mark
