[Stephan Kš╬per <Stephan.Kaemper / Schleswig-Holstein.de>, 2004-09-10 12.20 CEST]
> ---- Code starts here ----
> def silently
>   warn_level = $VERBOSE
>   $VERBOSE = false
>   res = yield
>   $VERBOSE = warn_level
>   res
> end
> 
> bark = puts ( "Here be Dragons!" )
> 
> keep_silent = silently do
>   any_line_of_code_will_do = 1
>   puts ( "Creatures under a smooth surface" )
>   nil
> end
> 
> bark = puts ( "Here be dragons!" )
> 
> ---- End of the Code ----
> 
> Remark: That really reads great: 'silently do ....' :-)
> (We might like to see just the opposite 'verbosely do' with warnings 
> switch on, no matter what.)
> 
> Now I came up with four ways to run this code: With or with out the '-w' 
> command line option and with or without the (apparently useless) line 
> commented out.
> 
> My expectation was ('is' actually) to get two warnings each way.
> However
> 
> Code run with |  No. of warnings
> --------------------------------
> #any...   -w  |    3
>  any...   -w  |    3
> #any...       |    3
>  any...       |    2
> 
> To get the result I expect, I apparently need to run the code without 
> the '-w' option and put some (useless) code before the line that might 
> create a warning.
> 
> I have to admit that I just don't get it...
> Why is that? Do you have any explanations?

I can't explain the "any_line_will_do" thing, but the warnings you are
getting ("don't puts spaces before arg parens") are compile-time (ie, when
your code is read). With $VERBOSE you can disable run-time warnings only
(because the variable is set at run time...).

* Compile time:
$ ruby -we 'puts ("Hi")'
-e:1: warning: (...) interpreted as grouped expression
Hi

$ ruby -we '$VERBOSE=nil; puts ("Hi")'
-e:1: warning: (...) interpreted as grouped expression
Hi

* Run time:
$ ruby -we 'A=1; A=2'
-e:1: warning: already initialized constant A

$ ruby -we '$VERBOSE=nil; A=1; A=2'

(no warning)
--